Part Number Hot Search : 
3050PA 1ZB22 AWL6950R B45197 D401M8 A5800515 1045C 00TTS
Product Description
Full Text Search
 

To Download UPSD3433E-40T6 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  july 2006 rev 4 1/293 293 upsd34xx turbo plus series fast turbo 8032 mcu with usb and programmable logic features summary fast 8-bit turbo 8032 mcu, 40 mhz ? advanced core, 4-clocks per instruction ? 10 mips peak performance at 40mhz (5v) ? jtag debug and in-system programming ? 16-bit internal instruction path fetches double-byte instruction in a single memory cycle ? branch cache & 4 instruction prefetch queue ? dual xdata pointers with automatic increment and decrement ? compatible with 3rd party 8051 tools dual flash memories with memory management ? place either memory into 8032 program address space or data address space ? read-while-write operation for in- application progra mming and eeprom emulation ? single voltage program and erase ? 100k guaranteed erase cycles, 15-year retention clock, reset, and power supply management ? sram is battery backup capable ? flexible 8-level cpu clock divider register ? normal, idle, and power down modes ? power-on and low voltage reset supervisor ? programmable watchdog timer programmable logic, general purpose ? 16 macrocells for logic applications (e.g., shifters, state machines, chip-selects, glue- logic to keypads, and lcds) a/d converter ? eight channels, 10-bit resolution, 6s figure 1. packages communication interfaces ? usb v2.0 full speed (12mbps) ? 10 endpoint pairs (in/out), each endpoint with 64-byte fifo (supports control, intr, and bulk transfer types) ?i 2 c master/slave controller, 833khz ? spi master controller, 10mhz ? two uarts with independent baud rate ? irda potocol: up to 115 kbaud ? up to 46 i/o, 5v tolerant upsd34xxv timers and interrupts ? three 8032 standard 16-bit timers ? programmable counter array (pca), six 16-bit modules for pwm, capcom, and timers ? 8/10/16-bit pwm operation ? 12 interrupt sources with two external interrupt pins operating voltage source (10%) ? 5v devices: 5.0v and 3.3v sources ? 3.3v devices: 3.3v source tqfp52 (t), 52-lead, thin, quad, flat tqfp80 (u), 80-lead, thin, quad, flat www.st.com
upsd34xx 2/293 note: operating temperature is in the industrial range (?40c to 85c). table 1. device summary part number max mhz 1st flash 2nd flash sram gpio 8032 bus v cc v dd pkg. (bytes) upsd3422e-40t6 40 64k 32k 4k 35 no 3.3v 5.0v tqfp52 upsd3422ev-40t6 40 64k 32k 4k 35 no 3.3v 3.3v tqfp52 upsd3422e-40u6 40 64k 32k 4k 46 yes 3.3v 5.0v tqfp80 upsd3422ev-40u6 40 64k 32k 4k 46 yes 3.3v 3.3v tqfp80 UPSD3433E-40T6 40 128k 32k 8k 35 no 3.3v 5.0v tqfp52 upsd3433ev-40t6 40 128k 32k 8k 35 no 3.3v 3.3v tqfp52 upsd3433e-40u6 40 128k 32k 8k 46 yes 3.3v 5.0v tqfp80 upsd3433ev-40u6 40 128k 32k 8k 46 yes 3.3v 3.3v tqfp80 upsd3434e-40t6 40 256k 32k 8k 35 no 3.3v 5.0v tqfp52 upsd3434ev-40t6 40 256k 32k 8k 35 no 3.3v 3.3v tqfp52 upsd3434e-40u6 40 256k 32k 8k 46 yes 3.3v 5.0v tqfp80 upsd3434ev-40u6 40 256k 32k 8k 46 yes 3.3v 3.3v tqfp80 upsd3454e-40t6 40 256k 32k 32k 35 no 3.3v 5.0v tqfp52 upsd3454ev-40t6 40 256k 32k 32k 35 no 3.3v 3.3v tqfp52 upsd3454e-40u6 40 256k 32k 32k 46 yes 3.3v 5.0v tqfp80 upsd3454ev-40u6 40 256k 32k 32k 46 yes 3.3v 3.3v tqfp80 upsd3422eb40t6 40 64k 32k 4k 35 no 3.3v 5.0v tqfp52 upsd3422evb40t6 40 64k 32k 4k 35 no 3.3v 3.3v tqfp52 upsd3422eb40u6 40 64k 32k 4k 46 yes 3.3v 5.0v tqfp80 upsd3422evb40u6 40 64k 32k 4k 46 yes 3.3v 3.3v tqfp80 upsd3433eb40t6 40 128k 32k 8k 35 no 3.3v 5.0v tqfp52 upsd3433evb40t6 40 128k 32k 8k 35 no 3.3v 3.3v tqfp52 upsd3433eb40u6 40 128k 32k 8k 46 yes 3.3v 5.0v tqfp80 upsd3433evb40u6 40 128k 32k 8k 46 yes 3.3v 3.3v tqfp80 upsd3434eb40t6 40 256k 32k 8k 35 no 3.3v 5.0v tqfp52 upsd3434evb40t6 40 256k 32k 8k 35 no 3.3v 3.3v tqfp52 upsd3434eb40u6 40 256k 32k 8k 46 yes 3.3v 5.0v tqfp80 upsd3434evb40u6 40 256k 32k 8k 46 yes 3.3v 3.3v tqfp80 upsd3454eb40t6 40 256k 32k 32k 35 no 3.3v 5.0v tqfp52 upsd3454evb40t6 40 256k 32k 32k 35 no 3.3v 3.3v tqfp52 upsd3454eb40u6 40 256k 32k 32k 46 yes 3.3v 5.0v tqfp80 upsd3454evb40u6 40 256k 32k 32k 46 yes 3.3v 3.3v tqfp80
upsd34xx contents 3/293 contents 1 summary description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2 pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3 hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4 memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.1 internal memory (mcu module, standard 8032 memory: data, idata, sfr) 20 4.2 external memory (psd module: program memory, data memory) . . . . . 20 5 8032 mcu core performance enhancements . . . . . . . . . . . . . . . . . . . . 23 5.1 pre-fetch queue (pfq) and branch cache (bc) . . . . . . . . . . . . . . . . . . . . 24 5.2 pfq example, multi-cycle instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 5.3 aggregate performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 6 mcu module description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 7 8032 mcu registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 7.1 stack pointer (sp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 7.2 data pointer (dptr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 7.3 program counter (pc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 7.4 accumulator (acc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 7.5 b register (b) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 7.6 general purpose registers (r0 - r7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 7.7 program status word (psw) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 8 special function registers (sfr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 9 8032 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 9.1 register addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 9.2 direct addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 9.3 register indirect addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 9.4 immediate addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
contents upsd34xx 4/293 9.5 external direct addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 9.6 external indirect addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 9.7 indexed addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 9.8 relative addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 9.9 absolute addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 9.10 long addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 9.11 bit addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 10 upsd34xx instruction set summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 11 dual data pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 11.1 data pointer control register, dptc (85h) . . . . . . . . . . . . . . . . . . . . . . . . 47 11.2 data pointer mode register, dptm (86h) . . . . . . . . . . . . . . . . . . . . . . . . . 48 12 debug unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 13 interrupt system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 13.1 individual interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 14 mcu clock generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 14.1 mcu_clk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 14.2 periph_clk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 15 power saving modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 15.1 idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 15.2 power-down mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 15.3 reduced frequency mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 16 oscillator and external com ponents . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 17 i/o ports of mcu module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 17.1 mcu port operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 18 mcu bus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 18.1 psen bus cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 18.2 read or write bus cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
upsd34xx contents 5/293 18.3 connecting external devices to the mcu bus . . . . . . . . . . . . . . . . . . . . . 78 18.4 programmable bus timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 18.5 controlling the pfq and bc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 19 supervisory functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 19.1 external reset input pin, reset_in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 19.2 low v cc voltage detect, lvd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 19.3 power-up reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 19.4 jtag debug reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 19.5 watchdog timer, wdt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 20 standard 8032 timer/counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 20.1 standard timer sfrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 20.2 clock sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 20.3 sfr, tcon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 20.4 sfr, tmod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 20.5 timer 0 and timer 1 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 20.6 timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 21 serial uart interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 21.1 uart operation modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 21.2 serial port control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 21.3 uart baud rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 21.4 more about uart mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 21.5 more about uart mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 21.6 more about uart modes 2 and 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 22 irda interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 22.1 baud rate selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 22.2 pulse width selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 23 i 2 c interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 23.1 i2c interface main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 23.2 communication flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 23.3 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
contents upsd34xx 6/293 23.4 bus arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 23.5 clock synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 23.6 general call address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 23.7 serial i/o engine (sioe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 23.8 i 2 c interface control register (s1con) . . . . . . . . . . . . . . . . . . . . . . . . . . 121 23.9 i 2 c interface status register (s1sta) . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 23.10 i2c data shift register (s1dat) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 23.11 i 2 c address register (s1adr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 23.12 i 2 c start sample setting (s1setup) . . . . . . . . . . . . . . . . . . . . . . . . . 125 23.13 i 2 c operating sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 24 spi (synchronous peripheral inte rface) . . . . . . . . . . . . . . . . . . . . . . . 134 24.1 spi bus features and communication flow . . . . . . . . . . . . . . . . . . . . . . . 135 24.2 full-duplex operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 24.3 bus-level activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 24.4 spi sfr registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 24.5 spi configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 24.6 dynamic control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 25 usb interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 25.1 basic usb concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 25.2 types of transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 25.3 endpoint fifos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 25.4 usb registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 25.5 typical connection to usb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 26 analog-to-digital convertor (a dc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 26.1 port 1 adc channel selects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 27 programmable counter array ( pca) with pwm . . . . . . . . . . . . . . . . . 175 27.1 pca block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 27.2 pca clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 27.3 operation of tcm modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 27.4 capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
upsd34xx contents 7/293 27.5 timer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 27.6 toggle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 27.7 pwm mode - (x8), fixed frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 27.8 pwm mode - (x8), programmable frequency . . . . . . . . . . . . . . . . . . . . . 179 27.9 pwm mode - fixed frequency, 16-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 27.10 pwm mode - fixed frequency, 10-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 27.11 writing to capture/compare registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 27.12 control register bit definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 27.13 tcm interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 28 psd module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 28.1 psd module functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 28.2 memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 28.3 psd module data bus width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 28.4 runtime control register definitions (csiop) . . . . . . . . . . . . . . . . . . . . . . 199 28.5 psd module detailed operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 28.6 psd module reset conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 29 ac/dc parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 30 maximum rating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 31 dc and ac parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 32 package mechanical information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 33 part numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 34 important notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 34.1 usb interrupts with idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 34.2 usb reset interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 34.3 usb reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 34.4 data toggle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 34.5 usb fifo accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 34.6 erroneous resend of data packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
contents upsd34xx 8/293 34.7 in fifo pairing operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 34.8 out fifo pairing operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 34.9 missing ack to host retransmission of setup packet . . . . . . . . . . . . . 289 34.10 mcu jtag id . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 34.11 port 1 not 5-volt io tolerant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 34.12 incorrect code execution when code banks are switched . . . . . . . . . . 291 34.13 9th received data bit corrupted in uart modes 2 and 3 . . . . . . . . . . 291 35 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
upsd34xx summary description 9/293 1 summary description the turbo plus upsd34xx series combines a powerful 8051-based microcontroller with a flexible memory structure, programmable logic, and a rich peripheral mix to form an ideal embedded controller. at its core is a fast 4-cycle 8032 mcu with a 4-byte instruction prefetch queue (pfq) and a 4-entry fully associative branching cache (bc). the mcu is connected to a 16-bit internal instruction path to maximize performance, enabling loops of code in smaller localit ies to execute extremely fast. the 16-bit wide instruction path in the turbo plus series allows double-byte instructions to be fetched from memory in a single memory cycle. this keeps the average perfo rmance near its peak performance (peak performance for 5v, 40mhz turbo plus upsd34xx is 10 mips for single-byte instructions, and average performance will be approximatel y 9 mips for mix of single- and multi-byte instructions). usb 2.0 (full speed, 12mbps) is included, providing 10 endpoints, each with its own 64-byte fifo to maintain high data throughput. endpoint 0 (control endpoint) uses two of the 10 endpoints for in and out directions, the remaining eight endpoints may be allocated in any mix to either type of transfers: bulk or interrupt. code development is easily managed without a hardware in-circuit emulator by using the serial jtag debug interface. jtag is also used for in-system programming (isp) in as little as 10 seconds, perfect for manufacturing and lab development. the 8032 core is coupled to programmable system device (psd) architecture to optimize the 8032 memory structure, offering two independent banks of flash memory that can be placed at virtually any address within 8032 program or data address space, and easily paged beyond 64k bytes using on- chip programmable decode logic. dual flash memory banks provide a robust solution for remote product updates in the field through in-application programming (iap). dual flash banks also support eeprom emulation, eliminating the ne ed for external eeprom chips. general purpose programmable logic (pld) is included to build an endless variety of glue- logic, saving external logic devices. the pld is configured using the software development tool, psdsoft express, available from the web at www.st.com/psm , at no charge. the upsd34xx also includes supervisor functions such as a programmable watchdog timer and low-voltage reset. note: for a list of known limitations of the upsd34xx devices, please refer to section 34: important notes .
summary description upsd34xx 10/293 figure 2. block diagram pa0:7 pb0:7 pd1:2 pc0:7 mcu bus p4.0:7 p1.0:7 p3.0:7 upsd34xx system bus dedicated pins supervisor: watchdog and low-voltage reset 1st flash memory: 64k, 128k, or 256k bytes 2nd flash memory: 32k bytes sram: 4k, 8k or 32k bytes programmable decode and page logic general purpose programmable logic, 16 macrocells (8) gpio, port a (80-pin only) (8) gpio, port b (4) gpio, port c (2) gpio, port d jtag ice and isp 8032 address/data/control bus (80-pin device only) v cc , v dd , gnd, reset, crystal in turbo 8032 core pfq & bc (3) 16-bit timer/ counters (2) external interrupts i 2 c spi (8) 10-bit adc uart0 (8) gpio, port 1 (8) gpio, port 3 (8) gpio, port 4 usb+, usb? usb v2.0, full speed 10 fifos uart1 optional irda encoder/decoder 16-bit pca (6) pwm, capcom, timer ai09695b
upsd34xx pin descriptions 11/293 2 pin descriptions figure 3. tqfp52 connections note: 1 for 5v applications, v dd must be connected to a 5.0v source. for 3.3v applications, v dd must be connected to a 3.3v source. 2 these signals can be used on one of two diff erent ports (port 1 or port 4) for flexibility. default is port1. 3av ref and 3.3v av cc are shared in the 52-pin package only. adc channels must use 3.3v as av ref for the 52-pin package. 39 p1.5/spirxd (2) /adc5 38 p1.4/spiclk (2) /adc4 37 p1.3/txd1(irda) (2) /adc3 36 p1.2/rxd1(irda) (2) /adc2 35 p1.1/t2x (2) /adc1 34 p1.0/t2 (2) /adc0 33 v dd (1) 32 xtal2 31 xtal1 30 p3.7/scl 29 p3.6/sda 28 p3.5/c1 27 p3.4/c0 pd1/clkin pc7 jtag tdo jtag tdi debug 3.3v v cc usb+ v dd (1) gnd usb? pc2/v stby jtag tck jtag tms 1 2 3 4 5 6 7 8 9 10 11 12 13 52 51 50 49 48 47 46 45 44 43 42 41 40 pb0 pb1 pb2 pb3 pb4 av cc /av ref (3) pb5 gnd reset_in pb6 pb7 p1.7/spisel (2) /adc7 p1.6/spitxd (2) /adc6 14 15 16 17 18 19 20 21 22 23 24 25 26 spisel (2) /pcaclk1/p4.7 spitxd (2) /tcm5/p4.6 spirxd (2) /tcm4/p4.5 spiclk (2) /tcm3/p4.4 txd1(irda) (2) /pcaclk0/p4.3 gnd rxd1(irda) (2) /tcm2/p4.2 t2x (2) /tcm1/p4.1 t2 (2) /tcm0/p4.0 rxd0/p3.0 txd0/p3.1 extint0/tg0/p3.2 extint1/tg1/p3.3 ai09696b
pin descriptions upsd34xx 12/293 figure 4. tqfp80 connections note: nc = not connected note: 1 the usb+ pin needs a 1.5k ? pull-up resistor. 2 for 5v applications, v dd must be connected to a 5.0v source. for 3.3v applications, v dd must be connected to a 3.3v source. 3 these signals can be used on one of two diff erent ports (port 1 or port 4) for flexibility. default is port1. 60 p1.5/spirxd (3) /adc5 59 p1.4/spiclk (3) /adc4 58 p1.3/txd1(irda) (3) /adc3 57 nc 56 p1.2/rxd1(irda) (3) /adc2 55 nc 54 p1.1/t2x (3) /adc1 53 nc 52 p1.0/t2 (3) /adc0 51 nc 50 v dd (1) 49 xtal2 48 xtal1 47 mcu ad7 46 p3.7/scl 45 mcu ad6 44 p3.6/sda 43 mcu ad5 42 p3.5/c1 41 mcu ad4 pd2/csi p3.3/tg1/exint1 pd1/clkin ale pc7 jtag tdo jtag tdi debug pc4/terr 3.3v v cc usb+ (1) v dd (2) gnd usb? pc3/tstat pc2/v stby jtag tck spisel (2) /pcaclk1/p4.7 spitxd (2) /tcm5/p4.6 jtag tms 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 pb0 p3.2/exint0/tg0 pb1 p3.1/txd0 pb2 p3.0/rxd0 pb3 pb4 av cc pb5 av ref gnd reset_in pb6 pb7 rd p1.7/spisel (3) /adc7 psen wr p1.6/spitxd (3) /adc6 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 pa7 pa6 spirxd (2) /tcm4/p4.5 pa5 spiclk (2) /tcm3/p4.4 pa4 txd1(irda) (2) /pcaclk0/p4.3 pa3 gnd rxd1(irda) (2) /tcm2/p4.2 t2x (2) /tcm1/p4.1 pa2 t2 (2) /tcm0/p4.0 pa1 pa0 mcu ad0 mcu ad1 mcu ad2 mcu ad3 p3.4/c0 ai09697b
upsd34xx pin descriptions 13/293 table 2. pin definitions port pin signal name 80-pin no. 52-pin no. (1) in/out function basic alternate 1 alternate 2 mcuad0 ad0 36 n/a i/o external bus multiplexed address/data bus a0/d0 mcuad1 ad1 37 n/a i/o multiplexed address/data bus a1/d1 mcuad2 ad2 38 n/a i/o multiplexed address/data bus a2/d2 mcuad3 ad3 39 n/a i/o multiplexed address/data bus a3/d3 mcuad4 ad4 41 n/a i/o multiplexed address/data bus a4/d4 mcuad5 ad5 43 n/a i/o multiplexed address/data bus a5/d5 mcuad6 ad6 45 n/a i/o multiplexed address/data bus a6/d6 mcuad7 ad7 47 n/a i/o multiplexed address/data bus a7/d7 p1.0 t2 adc0 52 34 i/o general i/o port pin timer 2 count input (t2) adc channel 0 input (adc0) p1.1 t2x adc1 54 35 i/o general i/o port pin timer 2 trigger input (t2x) adc channel 1 input (adc1) p1.2 rxd1 adc2 56 36 i/o general i/o port pin uart1 or irda receive (rxd1) adc channel 2 input (adc2) p1.3 txd1 adc3 58 37 i/o general i/o port pin uart or irda transmit (txd1) adc channel 3 input (adc3) p1.4 spiclk adc4 59 38 i/o general i/o port pin spi clock out (spiclk) adc channel 4 input (adc4) p1.5 spirxd adc5 60 39 i/o general i/o port pin spi receive (spirxd) adc channel 5 input (adc5) p1.6 spitxd adc6 61 40 i/o general i/o port pin spi transmit (spitxd) adc channel 6 input (adc6) p1.7 spisel adc7 64 41 i/o general i/o port pin spi slave select (spisel) adc channel 7 input (adc7)
pin descriptions upsd34xx 14/293 p3.0 rxd0 75 23 i/o general i/o port pin uart0 receive (rxd0) p3.1 txd0 77 24 i/o general i/o port pin uart0 transmit (txd0) p3.2 exint0 tgo 79 25 i/o general i/o port pin interrupt 0 input (extint0)/timer 0 gate control (tg0) p3.3 int1 2 26 i/o general i/o port pin interrupt 1 input (extint1)/timer 1 gate control (tg1) p3.4 c0 40 27 i/o general i/o port pin counter 0 input (c0) p3.5 c1 42 28 i/o general i/o port pin counter 1 input (c1) p3.6 sda 44 29 i/o general i/o port pin i 2 c bus serial data (i 2 csda) p3.7 scl 46 30 i/o general i/o port pin i 2 c bus clock (i 2 cscl) p4.0 t2 tcm0 33 22 i/o general i/o port pin program counter array0 pca0-tcm0 timer 2 count input (t2) p4.1 t2x tcm1 31 21 i/o general i/o port pin pca0-tcm1 timer 2 trigger input (t2x) p4.2 rxd1 tcm2 30 20 i/o general i/o port pin pca0-tcm2 uart1 or irda receive (rxd1) p4.3 txd1 pcaclk0 27 18 i/o general i/o port pin pcaclk0 uart1 or irda transmit (txd1) p4.4 spiclk tcm3 25 17 i/o general i/o port pin program counter array1 pca1-tcm3 spi clock out (spiclk) p4.5 spirxd tcm4 23 16 i/o general i/o port pin pca1-tcm4 spi receive (spirxd) p4.6 spitxd 19 15 i/o general i/o port pin pca1-tcm5 spi transmit (spitxd) p4.7 spisel pcaclk1 18 14 i/o general i/o port pin pcaclk1 spi slave select (spisel) av ref 70 n/a i reference voltage input for adc. connect av ref to vcc if the adc is not used. rd 65 n/a o read signal, external bus wr 62 n/a o write signal, external bus table 2. pin definitions port pin signal name 80-pin no. 52-pin no. (1) in/out function basic alternate 1 alternate 2
upsd34xx pin descriptions 15/293 psen 63 n/a o psen signal, external bus ale 4 n/a o address latch signal, external bus reset_in 68 44 i active low reset input xtal1 48 31 i oscillator input pin for system clock xtal2 49 32 o oscillator output pin for system clock debug 8 5 i/o i/o to the mcu debug unit pa0 35 n/a i/o general i/o port pin all port a pins support: 1. pld macro- cell outputs, or 2. pld inputs, or 3. latched address out (a0-a7), or 4. peripheral i/o mode pa1 34 n/a i/o general i/o port pin pa2 32 n/a i/o general i/o port pin pa3 28 n/a i/o general i/o port pin pa4 26 n/a i/o general i/o port pin pa5 24 n/a i/o general i/o port pin pa6 22 n/a i/o general i/o port pin pa7 21 n/a i/o general i/o port pin pb0 80 52 i/o general i/o port pin all port b pins support: 1. pld macro- cell outputs, or 2. pld inputs, or 3. latched address out (a0-a7 or a8-a15) pb1 78 51 i/o general i/o port pin pb2 76 50 i/o general i/o port pin pb3 74 49 i/o general i/o port pin pb4 73 48 i/o general i/o port pin pb5 71 46 i/o general i/o port pin pb6 67 43 i/o general i/o port pin pb7 66 42 i/o general i/o port pin jtagtms tms 20 13 i jtag pin (tms) jtagtck tck 17 12 i jtag pin (tck) pc2 v stby 16 11 i/o general i/o port pin sram standby voltage input (v stby ) pld macrocell output, or pld input pc3 tstat 15 n/a i/o general i/o port pin optional jtag status (tstat) pld, macrocell output, or pld input pc4 terr 9 n/a i/o general i/o port pin optional jtag status (terr ) pld, macrocell output, or pld input table 2. pin definitions port pin signal name 80-pin no. 52-pin no. (1) in/out function basic alternate 1 alternate 2
pin descriptions upsd34xx 16/293 note: 1 n/a = signal not available on 52-pin package. jtagtdi tdi 7 4 i jtag pin (tdi) jtagtdo tdo 6 3 o jtag pin (tdo) pc7 5 2 i/o general i/o port pin pld, macrocell output, or pld input pd1 clkin 3 1 i/o general i/o port pin 1. pld i/o 2. clock input to pld and apd pd2 csi 1 n/a i/o general i/o port pin 1. pld i/o 2. chip select ot psd module usb+ 11 7 i/o usb d+ pin; 1.5k ? pull-up resistor is required. usb? 14 10 i/o usb d? pin 3.3v-v cc 10 6 v cc - mcu module. connect av cc to v cc if the adc is not used. av cc 72 47 analog vcc input v dd 3.3v or 5v 12 8 v dd - psd module v dd - 3.3v for 3v v dd - 5v for 5v v dd 3.3v or 5v 50 33 v dd - psd module v dd - 3.3v for 3v v dd - 5v for 5v gnd 13 9 gnd 29 19 gnd 69 45 nc 51 n/a nc 53 n/a nc 55 n/a nc 57 n/a table 2. pin definitions port pin signal name 80-pin no. 52-pin no. (1) in/out function basic alternate 1 alternate 2
upsd34xx hardware description 17/293 3 hardware description the upsd34xx has a modular architecture built from a stacked die process. there are two die, one is designated ?mcu module? in this document, and the other is designated ?psd module? (see figure 5 on page 18 ). in all cases, the mcu module die operates at 3.3v with 5v tolerant i/o. the psd module is either a 3.3v die or a 5v die, depending on the upsd34xx device as described below. the mcu module consists of a fast 8032 core, that operates with 4 clocks per instruction cycle, and has many peripheral and system supervisor functions. the psd module provides the 8032 with multiple memories (two flash and one sram) for program and data, programmable logic for address decoding and fo r general-purpose logic, and additional i/o. the mcu module communicates with the psd module through internal address and data busses (ad0 ? ad15) an d control signals (rd , wr , psen , ale, reset ). there are slightly different i/o characteristics for each module. i/os for the mcu module are designated as ports 1, 3, and 4. i/os for the psd module are designated as ports a, b, c, and d. for all 5v upsd34xx devices, a 3.3v mcu module is stacked with a 5v psd module. in this case, a 5v upsd34xx device must be supplied with 3.3v cc for the mcu module and 5.0v dd for the psd module. ports 3 and 4 of the mcu module are 3.3v ports with tolerance to 5v devices (they can be directly driven by external 5v devices and they can directly drive external 5v devices while producing a v oh of 2.4v min and v cc max). ports a, b, c, and d of the psd module are true 5v ports. for all 3.3v upsd34xxv devices, a 3.3v mcu module is stacked with a 3.3v psd module. in this case, a 3.3v upsd34xx device needs to be supplied with a single 3.3v voltage source at both v cc and v dd . i/o pins on ports 3 and 4 are 5v tolerant and can be connected to external 5v peripherals devices if desired. ports a, b, c, and d of the psd module are 3.3v ports, which are not tolerant to external 5v devices. refer to ta b l e 3 for port type and voltage source requirements. 80-pin upsd34xx devices provide access to 8032 address, data, and control signals on external pins to connect external peripheral and memory devices. 52-pin upsd34xx devices do not provide access to the 8032 system bus. all non-volatile memory and configuration portions of the upsd34xx device are programmed through the jtag interface and no special programming voltage is needed. this same jtag port is also used for debugging of the 8032 core at runtime providing breakpoint, single-step, display, and trace features. a non-volatile security bit may be programmed to block all access via jtag interface for security. the security bit is defeated only by erasing the entire device, leavin g the device blank and ready to use again. table 3. port type and voltage source combinations device type v cc for mcu module v dd for psd module ports 1, 3, and 4 on mcu module ports a, b, c, and d on psd module 5v: upsd34xx 3.3v 5.0v 3.3v (ports 3 and 4 are 5v tolerant) 5v 3.3v: upsd34xxv 3.3v 3.3v 3.3v (ports 3 and 4 are 5v tolerant) 3.3v. not 5v tolerant
hardware description upsd34xx 18/293 figure 5. functional modules 10-bit adc dedicated memory interface prefetch, branch cache enhanced mcu interface decode pld psd page register sram cpld - 16 macrocells jtag isp reset logic wdt internal reset port 1 port 3 dual uarts interrupt 3 timer / counters 256 byte sram turbo 8032 core psd internal bus 8032 internal bus psd reset lvd i 2 c unit usb and trans- ceiver port d gpio port c jtag and gpio secondary flash reset input upsd34xx jtag debug 8-bit/16-bit die-to-die bus main flash pca pwm counters reset pin ext. bus spi v cc pins 3.3v v dd pins 3.3v or 5v mcu module psd module port 3 - uart0, intr, timers port 1 - timer, adc, spi port 4 - pca, pwm, uart1 port 3 i 2 c usb pins xtal clock unit port a,b,c pld i/o and gpio ai10409
upsd34xx memory organization 19/293 4 memory organization the 8032 mcu core views memory on the mcu module as ?internal? memory and it views memory on the psd module as ?external? memory, see figure 6 internal memory on the mcu module consists of data, idata, and sfrs. these standard 8032 memories reside in 384 bytes of sram located at a fixed address space starting at address 0x0000. external memory on the psd module consists of four types: main flash (64k, 128k, or 256k bytes), a smaller secondary flash (32k), sram (4k, 8k or 32kbytes), and a block of psd module control registers called csiop (256 bytes). these external memories reside at programmable address ranges, specified using the software tool psdsoft express. see the psd module section of this document for more details on these memories. external memory is accessed by the 8032 in two separate 64k byte address spaces. one address space is for program memory and the other address space is for data memory. program memory is accesse d using the 8032 signal, psen . data memory is accessed using the 8032 signals, rd and wr . if the 8032 needs to access more than 64k bytes of external program or data memory, it must use paging (or banking) techniques provided by the page register in the psd module. note: when referencing program and data memory spaces, it has nothing to do with 8032 internal sram areas of data, idata, and sfr on the mcu module. program and data memory spaces only relate to the external memories on the psd module. external memory on the psd module can overlap the internal sram memory on the mcu module in the same physical address range (starting at 0x0000) without interference because the 8032 core does not assert the rd or wr signals when accessing internal sram. figure 6. upsd34xx memories  external memories may be placed at virtually any address using software tool psdsoft express.  the sram and flash memories may be placed in 8032 program space or data space using psdsoft express.  any memory in 8032 data space is xdata. 64kb or 128kb or 256kb 32kb main flash internal sram on mcu module external memory on psd module i data sfr data secondary flash 4kb or 8kb or 32kb sram 384 bytes sram direct or indirect addressing ff 80 7f 128 bytes 128 bytes 128 bytes 0 indirect addressing fixed addresses direct addressing ai10410b
memory organization upsd34xx 20/293 4.1 internal memory (mcu module, standard 8032 memory: data, idata, sfr) 4.1.1 data memory the first 128 bytes of internal sram ranging from address 0x0000 to 0x007f are called data, which can be ac cessed using 8032 direct or indirect addressing schemes and are typically used to store variables and stack. four register banks, each with 8 registers (r0 ? r7), occupy addresses 0x0000 to 0x001f. only one of these four banks may be enabled at a time. the next 16 locations at 0x0020 to 0x002f contain 128 directly addressable bit locations that can be used as software flags. sram locations 0x0030 and above may be used for variables and stack. 4.1.2 idata memory the next 128 bytes of internal sram are named idata and range from address 0x0080 to 0x00ff. idata can be accessed only through 8032 indirect addressing and is typically used to hold the mcu stack as well as data variables. the stack can reside in both data and idata memories and reach a size limited only by the available space in the combined 256 bytes of these two memories (since stack accesses are always done using indirect addressing, the boundary between data and idata does not exist with regard to the stack). 4.1.3 sfr memory special function registers ( table 5 on page 32 ) occupy a separate physical memory, but they logically overlap the same 128 bytes as idata, ranging from address 0x0080 to 0x00ff. sfrs are accessed only using direct addressing . there 86 active registers used for many functions: changing the operatin g mode of the 8032 m cu core, controlling 8032 peripherals, controlling i/o, and managing inte rrupt functions. the re maining unused sfrs are reserved and should not be accessed. 16 of the sfrs are both byte- and bit-addressable. bit-addressable sfrs are those whose address ends in ?0? or ?8? hex. 4.2 external memory (psd module: program memory, data memory) the psd module has four memories: main flas h, secondary flash, sram, and csiop. see the psd module section for more detailed information on these memories. memory mapping in the psd module is im plemented with the decode pld (dpld) and optionally the page register. the user specifies decode equations for individual segments of each of the memories using the software tool psdsoft express. this is a very easy point- and-click process allowing total flexibility in mapping memories. additionally, each of the memories may be placed in various combinations of 8032 program address space or 8032 data address space by using the software tool psdsoft express.
upsd34xx memory organization 21/293 4.2.1 program memory external program memory is addressed by the 8032 using its 16-bit program counter (pc) and is accessed with the 8032 signal, psen . program memory can be present at any address in program space between 0x0000 and 0xffff. after a power-up or reset, the 8032 begins program execution from location 0x0000 where the reset vector is stored, causing a jump to an initialization routine in firmware. at address 0x0003, just following the reset vector are the interrupt service locations. each interrupt is assigned a fixed interrupt service location in program memory. an interrupt causes the 8032 to jump to that service location, where it commences execution of the service routine. external interrupt 0 (exint0), for example, is assigned to service location 0x0003. if exint0 is going to be used, its service routine must begin at location 0x0003. interrupt service locations are spaced at 8-byte intervals: 0x0003 for exint0, 0x000b for timer 0, 0x0013 for exint1, and so forth. if an interrupt service routine is short enough, it can reside entirely within the 8-byte interval. longer service routines can use a jump instruction to somewhere else in program memory. 4.2.2 data memory external data is referred to as xdata and is addressed by the 8032 using indirect addressing via its 16-bit data pointer register (dptr) and is accessed by the 8032 signals, rd and wr . xdata can be present at any address in data space between 0x0000 and 0xffff. note: the upsd34xx has dual data pointers (source and destination) making xdata transfers much more efficient. 4.2.3 memory placement psd module architecture allows the placement of its external memories into different combinations of program memory and data memory spaces. this means the main flash, the secondary flash, and the sram can be viewed by the 8032 mcu in various combinations of program memory or data memory as defined by psdsoft express. as an example of this flexibility, for applications that require a great de al of flash memory in data space (large lookup tables or extended data recording), the larger main flash memory can be placed in data space and the smaller secondary flash memory can be placed in program space. the opposite can be realized for a different application if more flash memory is needed for code and less flash memory for data. by default, the sram and csiop memories on the psd module must always reside in data memory space and they are treated by the 8032 as xdata. the main flash and secondary flash memories may reside in program space, data space, or both. these memory placement choices specified by psdsoft express are programmed into non-volatile sections of the upsd34xx, and are active at power-up and after reset. it is possible to override these initial settings during runtime for in-application programming (iap). standard 8032 mcu architecture cannot write to its own program memory space to prevent accidental corruption of firmware. however, this becomes an obstacle in typical 8032 systems when a remote update to firmware in flash memory is required using iap. the psd module provides a solution for remote updates by allowing 8032 firmware to temporarily ?reclassify? flash memory to reside in data space during a remote update, then returning
memory organization upsd34xx 22/293 flash memory back to program space when finished. see the vm register ( ta b l e 1 0 4 o n page 197 ) in the psd module section of this document for more details.
upsd34xx 8032 mcu core performance enhancements 23/293 5 8032 mcu core performance enhancements before describing performance features of the upsd34xx, let us first look at standard 8032 architecture. the clock source for the 8032 mcu creates a basic unit of timing called a machine-cycle, which is a period of 12 clocks for standard 8032 mcus. the instruction set for traditional 8032 mcus consists of 1, 2, and 3 byte instructions that execute in different combinations of 1, 2, or 4 machine-cycles. for example, there are one-byte instructions that execute in one machine-cycle (12 clocks), one- byte instructions that execute in four machine-cycles (48 clocks), two-byte, two-cycl e instructions (24 clocks), and so on. in addition, standard 8032 architecture will fetch two bytes from program memory on almost every machine-cycle, regardless if it needs them or not (dummy fetch). this means for one- byte, one-cycle instructions, the second byte is ignored. these one-byte, one-cycle instructions account for half of the 8032's instructions (126 out of 255 opcodes). there are inefficiencies due to wasted bus cycles and idle bus times that can be eliminated. the upsd34xx 8032 mcu core offers increased performance in a number of ways, while keeping the exact same instruction set as the standard 8032 (all opcodes, the number of bytes per instruction, and the native number a machine-cycles per instruction are identical to the original 8032). the first way performance is boosted is by reducing the machine-cycle period to just 4 mcu clocks as compared to 12 mcu clocks in a standard 8032. this shortened machine-cycle improves the instruct ion rate for one- or two-byte, one-cycle instructions by a factor of three ( figure 7 on page 23 ) compared to standard 8051 architectures, and significantly improves pe rformance of multiple-cycle instruction types. the example in figure 7 on page 23 shows a continuous execution stream of one- or two- byte, one-cycle instructions. the 5v upsd34xx will yield 10 mips peak performance in this case while operating at 40mhz clock rate. in a typical application however, the effective performance will be lower since programs do not use only one-cycle instructions, but special techniques are implemented in the upsd34xx to keep the effective mips rate as close as possible to the peak mips rate at all time s. this is accomplished with an instruction pre- fetch queue (pfq), a branch cache (bc), and a 16-bit program memory bus as shown in figure 8 on page 24 . figure 7. comparison of upsd34xx with standard 8032 performance mcu clock standard 8032 fetch byte for instruction a execute instruction a and fetch a second dummy byte turbo upsd34xx execute instruction and pre-fetch next instruction 4 clocks (one machine cycle) 12 clocks (one machine cycle) 1- or 2-byte, 1-cycle instructions dummy byte is ignored (wasted bus access) execute instruction and pre-fetch next instruction execute instruction and pre-fetch next instruction instruction a instruction b instruction c instruction a turbo upsd34xx executes instructions a, b, and c in the same amount of time that a standard 8032 executes only instruction a. one machine cycle one machine cycle ai10411
8032 mcu core performance enhancements upsd34xx 24/293 figure 8. instruction pre-fetch queue and branch cache 5.1 pre-fetch queue (pfq) and branch cache (bc) the pfq is always working to minimize the idle bus time inherent to 8032 mcu architecture, to eliminate wasted memory fetches, and to maximize memory bandwidth to the mcu. the pfq does this by running asynchronously in relation to the mcu, looking ahead to pre-fetch two bytes (word) of code from program memory during any idle bus periods. only necessary word will be fetched (no dummy fetches like st andard 8032). the pfq will queue up to four code bytes in advance of execution, which significantly optimizes sequential program performance. however, when program execution becomes non-sequential (program branch), a typical pre-fetch queue will empty it self and reload new code, causing the mcu to stall. the turbo upsd34xx diminishes this problem by using a branch cache with the pfq. the bc is a four-way, fully associative cache, meaning that when a program branch occurs, its branch destination address is compared simultaneously with four recent previous branch destinations stored in the bc. each of the four cache entries contain up to four bytes of code related to a branch. if there is a hit (a match), then all four code bytes of the matching program branch are transferred immediately and simultaneously from the bc to the pfq, and execution on that branch continues with minimal delay. this greatly reduces the chance that the mcu will stall from an empty pfq, and improves pe rformance in embedded control systems where it is quite common to branch and loop in relatively small code localities. by default, the pfq and bc are enabled after power-up or reset. the 8032 can disable the pfq and bc at runtime if desired by writing to a specific sfr (buscon). the memory in the psd module operates with variable wait states depending on the value specified in the sfr named buscon. for example, a 5v upsd34xx device operating at a 40mhz crystal frequency requires four memory wait states (equal to four mcu clocks). in this example, once the pfq has one word of code, the wait states become transparent and a full 10 mips is achieved when the program stream consists of sequential one- or two-byte, one machine-cycle instructions as shown in figure 7 on page 23 (transparent because a machine-cycle is four mcu clocks which equals the memory pre-fetch wait time that is also branch 4 code branch 4 code 8032 mcu 16-bit program memory on psd module instruction pre-fetch queue (pfq) 4 bytes of instruction instruction byte wait wait 8 instruction byte 8 instruction byte 8 current branch address compare branch cache (bc) 16 ai10431 address 16 16 16 address load on branch address match branch 3 code branch 3 code branch 2 code branch 2 code branch 1 code branch 1 code
upsd34xx 8032 mcu core performance enhancements 25/293 four mcu clocks). but it is also important to understand pfq operation on multi-cycle instructions. 5.2 pfq example, multi-cycle instructions let us look at a string of two-byte, two-cycle instructions in figure 9 on page 25 . there are three instructions executed sequ entially in this example, instru ctions a, b, and c. each of the time divisions in the figure is one machine-cycle of four clocks, and there are six phases to reference in this discussion. each instruction is pre-fetched into the pfq in advance of execution by the mcu. prior to phase 1, the pfq has pre-fetched the two instruction bytes (a1 and a2) of instruction a. during phase one, both bytes are loaded into the mcu execution unit. also in phase 1, the pfq is pre-fetching instruction b (bytes b1 and b2) from program memory. in phase 2, the mcu is proc essing instruction a internally while the pfq is pre-fetching instruction c. in phase 3, both bytes of instruction b are loaded into the mcu execution unit and the pfq begins to pre-fetch bytes for the next instruction. in phase 4 instruction b is processed. the upsd34xx mcu instructions are an exact 1/3 scale of all standard 8032 instructions with regard to number of cycles per instruction. figure 10 on page 26 shows the equivalent instruction sequence from the example above on a standard 8032 for comparison. 5.3 aggregate performance the stream of two-byte, two-cycle instructions in figure 9 on page 25 , running on a 40mhz, 5v, upsd34xx will yield 5 mips. and we saw the stream of one- or two-byte, one-cycle instructions in figure 7 on page 23 , on the same mcu yield 10 mips. effective performance will depend on a number of things : the mcu clock frequency; th e mixture of instructions types (bytes and cycles) in the application; th e amount of time an empty pfq stalls the mcu (mix of instruction types and misses on branch cache); and the operating voltage. a 5v upsd34xx device operates with four memory wait states, but a 3.3v device operates with five memory wait states yielding 8 mips peak compared to 10 mips peak for 5v device. the same number of wait states will apply to bo th program fetches and to data read/writes unless otherwise specified in the sfr named buscon. in general, a 3x aggregate performance increase is expected over any standard 8032 application running at the same clock frequency. figure 9. pfq operation on multi-cycle instructions three 2-byte, 2-cycle instructions on upsd34xx pfq mcu execution inst a, byte 1&2 inst b, byte 1&2 inst c, byte 1&2 next inst previous instruction a1 a2 process a b1 b2 process b c1 c2 ai10432 process c continue to pre-fetch next inst 4-clock macine cycle instruction a instruction b instruction c pre-fetch inst a pre-fetch inst b and c pre-fetch next inst phase 1 phase 2 phase 3 phase 4 phase 6 phase 5
8032 mcu core performance enhancements upsd34xx 26/293 figure 10. upsd34xx multi-cycle instructions compared to standard 8032 a1 a2 inst a b1 b2 inst b c1 c2 inst c three 2-byte, 2-cycle instructions, upsd34xx vs. standard 8032 upsd34xx std 8032 72 clocks (12 clocks per cycle) 24 clocks total (4 clocks per cycle) byte 1 byte 2 process inst a byte 1 byte 2 process inst b byte 1 byte 2 process inst c ai10412 1 cycle 1 cycle
upsd34xx mcu module description 27/293 6 mcu module description this following sections provide a detailed descr iption of the mcu module system functions and peripherals, including: 8032 mcu registers special function registers 8032 addressing modes upsd34xx instruct ion set summary dual data pointers debug unit interrupt system mcu clock generation power saving modes oscillator and exte rnal components i/o ports mcu bus interface supervisory functions standard 8032 timer/counters serial uart interfaces irda interface i 2 c interface spi interface analog to digital converter programmable counter array (pca) usb interface
8032 mcu registers upsd34xx 28/293 7 8032 mcu registers the upsd34xx has the following 8032 mcu core registers, also shown in figure 11 . figure 11. 8032 mcu registers 7.1 stack pointer (sp) the sp is an 8-bit register which holds the current location of the top of the stack. it is incremented before a value is pushed onto the stack, and decremented after a value is popped off the stack. the sp is initialized to 07h after reset. this causes the stack to begin at location 08h (top of stack). to avoid overlapping conflicts, the user must initialize the top of the stack to 20h if all four banks of registers r0 - r7 are used, as well as the top of stack to 30h if all of the 8032 bit memory locations are used. 7.2 data pointer (dptr) dptr is a 16-bit register consisting of two 8-bit registers, dpl and dph. the dptr register is used as a base register to create an address for indirect jumps, table look-up operations, and for external data transfers (xdata). when not used for addressing, the dptr register can be used as a general purpose 16-bit data register. very frequently, the dptr register is used to access xdata using the external direct addressing mode. the upsd34xx has a special set of sfr registers (dptc, dptm) to control a secondary dptr register to speed memory-to-memory xdata transfers. having dual dptr registers allows rapid switching between source and destination addresses (see details in section 11: dual data pointers on page 47 ). 7.3 program counter (pc) the pc is a 16-bit register consisting of two 8-bit registers, pcl and pch. this counter indicates the address of the next instruction in program memory to be fetched and executed. a reset forces the pc to location 0000h, which is where the reset jump vector is stored. 7.4 accumulator (acc) this is an 8-bit general purpose register wh ich holds a source operand and receives the result of arithmetic operations. the acc register can also be the source or destination of logic and data movement operations. for mul and div instructions, acc is combined with ai06636 accumulator b register stack pointer program counter program status word general purpose register (bank0-3) data pointer register pch dptr(dph) a b sp pcl psw r0-r7 dptr(dpl)
upsd34xx 8032 mcu registers 29/293 the b register to hold 16-bit operands. the acc is referred to as ?a? in the mcu instruction set. 7.5 b register (b) the b register is a general purpose 8-bit register for temporary data storage and also used as a 16-bit register when concatenated with the acc register for use with mul and div instructions. 7.6 general purpose registers (r0 - r7) there are four banks of eight general purpose 8-bit registers (r0 - r7), but only one bank of eight registers is active at any given time depending on the setting in the psw word (described next). r0 - r7 are generally used to assist in manipulating values and moving data from one memory location to another. thes e register banks physically reside in the first 32 locations of 8032 internal data sram, starting at address 00h. at reset, only the first bank of eight registers is active (addresses 00h to 07h), and the stack begins at address 08h. 7.7 program status word (psw) the psw is an 8-bit register which stores several important bits, or flags, that are set and cleared by many 8032 instructions, reflecting the current state of the mcu core. figure 12 on page 30 shows the individual flags. 7.7.1 carry flag (cy) this flag is set when the last arithmetic operation that was executed results in a carry (addition) or borrow (subtraction). it is cleared by all other arithmetic operations. the cy flag is also affected by shift and rotate instructions. 7.7.2 auxiliary carry flag (ac) this flag is set when the last arithmetic operation that was executed results in a carry into (addition) or borrow from (subtraction) the high-order nibble. it is cleared by all other arithmetic operations. 7.7.3 general purpose flag (f0) this is a bit-addressable, general-purpose flag for use under software control. 7.7.4 register bank se lect flags (rs1, rs0) these bits select which bank of eight registers is used during r0 - r7 register accesses (see ta b l e 4 ) 7.7.5 overflow flag (ov) the ov flag is set when: an add, addc, or subb instruction causes a sign change; a mul instruction results in an overflow (result greater than 255); a div instruction causes a divide-
8032 mcu registers upsd34xx 30/293 by-zero condition. the ov flag is cleared by the add, addc, subb, mul, and div instructions in all other cases. the clrv in struction will clear the ov flag at any time. 7.7.6 parity flag (p) the p flag is set if the sum of the eight bits in the accumulator is odd, and p is cleared if the sum is even. table 4. .register bank select addresses figure 12. program status word (psw) register rs1 rs0 register bank 8032 internal data address 0 0 0 00h - 07h 0 1 1 08h - 0fh 1 0 2 10h - 17h 1 1 3 18h - 1fh ai06639 cy reset value 00h parity flag bit not assigned overflow flag register bank select flags (to select bank0-3) carry flag auxillary carry flag general purpose flag ac fo rs1 rs0 ov p msb lsb psw
upsd34xx special function registers (sfr) 31/293 8 special function registers (sfr) a group of registers designated as specia l function register (sfr) is shown in table 5 on page 32 . sfrs control the operating modes of the mcu core and also control the peripheral interfaces and i/o pins on the mcu module. th e sfrs can be accessed only by using the direct addressing method within the address range from 80h to ffh of internal 8032 sram. sixteen addresses in sfr address space are both byte- and bit-addressable. the bit- addressable sfrs are noted in ta b l e 5 . 106 of a possible 128 sfr addresses are occupied. the remaining unoccupied sfr addresses (designated as ?reserved? in ta b l e 5 ) should not be written. reading unoccupied locations will retu rn an undefined value. note: there is a separate set of control registers for the psd module, designated as csiop, and they are described in the section 28: psd module on page 185 . the i/o pins, pld, and other functions on the psd module are not controlled by sfrs. sfrs are categorized as follows: mcu core registers: ip, a, b, psw, sp, dptl, dpth, dptc, dptm mcu module i/o port registers: p1, p3, p4, p1sfs0, p1sfs1 , p3sfs, p4sfs0, p4sfs1 standard 8032 timer registers tcon, tmod, t2con, th0, th1, th2, tl0, tl1, tl2, rcap2l, rcap2h standard serial interfaces (uart) scon0, sbuf0, scon1, sbuf1 power, clock, and bus timing registers pcon, ccon0, ccon1, buscon hardware watchdog timer registers wdkey, wdrst interrupt system registers ip, ipa, ie, iea prog. counter array (pca) control registers pcacl0, pcach0, pcacon0, pcasta, pcacl1, pcach1, pcacon1, ccon2, ccon3 pca capture/compare and pwm registers capcoml0, capcomh0, tcmmode0, capcoml1, capcomh1, tcmmode2, capcoml2, capcomh2, tcmmode2, capcoml3, capcomh3, tcmmode3,
special function registers (sfr) upsd34xx 32/293 capcoml4, capcomh4, tcmmode4, capcoml5, capcomh5, tcmmode5, pwmf0, pmwf1 spi interface registers spiclkd, spistat, spitdr, spirdr, spicon0, spicon1 i 2 c interface registers s1setup, s1con, s1sta, s1dat, s1adr analog to digital converter registers acon, adcps, adat0, adat1 irda interface register irdacon usb interface registers uaddr, upair, we0-3, uif0-3, uctl, usta, usel, ucon, usize, ubaseh, ubasel, usci, uscv table 5. sfr memory map with direct address and reset value sfr addr sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210 80 reserved 81 sp sp[7:0] 07 section 7.1 82 dpl dpl[7:0] 00 section 7.2 83 dph dph[7:0] 00 84 reserved 85 dptc ? at ? ? ? dpsel[2:0] 00 ta bl e 1 3 86 dptm ? ? ? ? md1[1:0] md0[1:0] 00 ta bl e 1 4 87 pcon smod0 smod1 ? por rclk1 tclk1 pd idle 00 ta bl e 2 6 88 (1) tcon tf1 <8fh> tr1 <8eh> tf0 <8dh> tr0 <8ch> ie1 <8bh> it1 <8ah> ie0 <89h> it0 <88h> 00 ta bl e 4 1 89 tmod gate c/t m1 m0 gate c/t m1 m0 00 ta bl e 4 2 8a tl0 tl0[7:0] 00 section 20.1 8b tl1 tl1[7:0] 00 8c th0 th0[7:0] 00 8d th1 th1[7:0] 00 8e p1sfs0 p1sfs0[7:0] 00 ta bl e 3 1 8f p1sfs1 p1sfs1[7:0] 00 ta bl e 3 2 90 (1) p1 p1.7 <97h> p1.6 <96h> p1.5 <95h> p1.4 <94h> p1.3 <93h> p1.2 <92h> p1.1 <91h> p1.0 <90h> ff ta bl e 2 7 91 p3sfs p3sfs[7:0] 00 ta bl e 3 0 92 p4sfs0 p4sfs0[7:0] 00 ta bl e 3 4 93 p4sfs1 p4sfs1[7:0] 00 ta bl e 3 5
upsd34xx special function registers (sfr) 33/293 94 adcps ? ? ? ? adcce adcps[2:0] 00 ta bl e 9 0 95 adat0 adata[7:0] 00 ta bl e 9 1 96 adat1 ? ? ? ? ? ? adata[9:8] 00 ta bl e 9 2 97 acon aintf ainten aden ads[2:0] adst adsf 00 ta bl e 8 9 98 (1) scon0 sm0 <9fh> sm1 <9eh> sm2 <9dh> ren <9ch> tb8 <9bh> rb8 <9ah> ti <99h> ri <9h8> 00 ta bl e 4 7 99 sbuf0 sbuf0[7:0] 00 section 21 9a reserved 9b reserved 9c reserved 9d busco n epfq ebc wrw1 wrw0 rdw1 rdw0 cw1 cw0 eb ta bl e 3 7 9e reserved 9f reserved a0 reserved a1 reserved a2 pcacl0 pcacl0[7:0] 00 ta bl e 9 3 a3 pcach0 pcach0[7:0] 00 ta bl e 9 3 a4 pcaco n0 en_all en_pca eovf1 pca_idl ? ? clk_sel[1:0] 00 ta bl e 9 6 a5 pcasta ovf1 intf5 intf4 intf3 ovf0 intf2 intf1 intf0 00 ta bl e 9 8 a6 wdrst wdrst[7:0] 00 ta bl e 4 0 a7 iea eadc espi epca es1 ? ? ei2c ? 00 ta bl e 1 8 a8 (1) ie ea ? et2 es0 et1 ex1 et0 ex0 00 ta bl e 1 7 a9 tcmmo de0 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 ta bl e 9 9 aa tcmmo de1 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 ab tcmmo de2 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 ac capco ml0 capcoml0[7:0] 00 ta bl e 9 3 ad capco mh0 capcomh0[7:0] 00 ae wdkey wdkey[7:0] 55 ta bl e 3 9 table 5. sfr memory map with direct address and reset value sfr addr sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
special function registers (sfr) upsd34xx 34/293 af capco ml1 capcoml1[7:0] 00 ta bl e 9 3 b0 (1) p3 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 ff ta bl e 2 8 b1 capco mh1 capcomh1[7:0] 00 ta bl e 9 3 b2 capco ml2 capcoml2[7:0] 00 b3 capco mh2 capcomh2[7:0] 00 b4 pwmf0 pwmf0[7:0] 00 b5 reserved b6 reserved b7 ipa padc pspi ppca ps1 ? ? pi2c ? 00 ta bl e 2 0 b8 (1) ip ? ? pt2 ps0 pt1 px1 pt0 px0 00 ta bl e 1 9 b9 reserved ba pcacl1 pcacl1[7:0] 00 ta bl e 9 3 bb pcach1 pcach1[7:0] 00 bc pcaco n1 ? en_pca eovf1 pca_idl ? ? clk_sel[1:0] 00 ta bl e 9 7 bd tcmmo de3 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 ta bl e 9 9 be tcmmo de4 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 bf tcmmo de5 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] 00 c0 (1) p4 p4.7 p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 p4.0 ff ta bl e 2 9 table 5. sfr memory map with direct address and reset value sfr addr sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
upsd34xx special function registers (sfr) 35/293 c1 capco ml3 capcoml3[7:0] 00 ta bl e 9 3 c2 capco mh3 capcomh3[7:0] 00 c3 capco ml4 capcoml4[7:0] 00 c4 capco mh4 capcomh4[7:0] 00 c5 capco ml5 capcoml5[7:0] 00 c6 capco mh5 capcomh5[7:0] 00 c7 pwmf1 pwmf1[7:0] 00 c8 (1) t2con tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl2 00 ta bl e 4 3 c9 reserved ca rcap2l rcap2l[7:0] 00 section 20.1 cb rcap2h rcap2h[7:0] 00 cc tl2 tl2[7:0] 00 cd th2 th2[7:0] 00 ce irdaco n ? irda_en bit_puls cdiv4 cdiv3 cdiv2 cdiv1 cdiv0 0f ta bl e 5 0 d0 (1) psw cy ac f0 rs[1:0] ov ? p 00 section 7.7 d1 reserved d2 spiclk d spiclkd[5:0] ? ? 04 ta bl e 6 5 d3 spistat ? ? ? busy teisf rorisf tisf risf 02 ta bl e 6 6 d4 spitdr spitdr[7:0] 00 ta bl e 6 4 d5 spirdr spirdr[7:0] 00 d6 spicon 0 ? te re spien ssel flsb spo ? 00 ta bl e 6 3 d7 spicon 1 ? ? ? ? teie rorie tie rie 00 ta bl e 6 4 d8 (1) scon1 sm0 sm2
ren tb8 rb8 ti ri 00 ta bl e 4 8 d9 sbuf1 sbuf1[7:0] 00 section 21 table 5. sfr memory map with direct address and reset value sfr addr sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
special function registers (sfr) upsd34xx 36/293 da reserved db s1setu p ss_en smpl_set[6:0] 00 ta bl e 5 9 dc s1con cr2 en1 sta sto addr aa cr1 cr0 00 ta bl e 5 4 dd s1sta gc stop intr tx_md b_busy b_lost ack_r slv 00 ta bl e 5 6 de s1dat s1dat[7:0] 00 ta bl e 5 7 df s1adr s1adr[7:0] 00 ta bl e 5 8 e0 (1) a a[7:0] 00 section 7.4 e1 reserved e2 uaddr ? usbaddr[6:0] 00 e3 upair ? ? ? ? pr3out pr1out pr3in pr1in 00 e4 uie0 ? ? ? ? rstie suspnd ie eopie res umie 00 e5 uie1 ? ? ? in4ie in3ie in2ie in1ie in0ie 00 e6 uie2 ? ? ? out4ie out3ie out2ie out1ie out0ie 00 e7 uie3 ? ? ? nak4ie nak3ie nak2ie nak1ie nak0ie 00 e8 uif0 glf inf outf nakf rstf suspnd f eopf resum f 00 e9 uif1 ? ? ? in4f in3f in2f in1f in0f 00 ea uif2 ? ? ? out4f out3f out2f out1f out0f 00 eb uif3 ? ? ? nak4f nak3f nak2f nak1f nak0f 00 ec uctl ? ? ? ? ? usben visible wakeu p 00 ed usta ? ? ? ? rcvt setup in out 00 ee reserved ef usel dir ? ? ? ? ep[2:0] 00 f0 (1) b b[7:0] 00 section 7.5 f1 ucon ? ? ? ? enable stall toggle bsy 08 f2 usize ? size[6:0] 00 f3 ubaseh baseaddr[15:8] 00 f4 ubasel baseaddr[7:6] 0 0 0 0 0 0 00 f5 usci ? ? ? ? ? usci[2:0] 00 f6 uscv uscv[7:0] 00 table 5. sfr memory map with direct address and reset value sfr addr sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
upsd34xx special function registers (sfr) 37/293 note: 1 this sfr can be addressed by individual bits (bit address mode) or addressed by the entire byte (direct address mode). f7 reserved f8 reserved f9 ccon0 pllm[4] pllen upllce dbgce cpu_ ar cpups[2:0] 50 ta bl e 2 2 fa ccon1 pllm[3:0] plld[3:0] 00 fb ccon2 ? ? ? pca0ce pca0ps[3:0] 10 ta bl e 9 4 fc ccon3 ? ? ? pca1ce pca1ps[3:0] 10 ta bl e 9 5 fd reserved fe reserved ff reserved fe reserved ff reserved table 5. sfr memory map with direct address and reset value sfr addr sfr name bit name and reset value (hex) reg. descr. with link 76 5 43210
8032 addressing modes upsd34xx 38/293 9 8032 addressing modes the 8032 mcu uses 11 different addressing modes listed below: register direct register indirect immediate external direct external indirect indexed relative absolute long bit 9.1 register addressing this mode uses the contents of one of the registers r0 - r7 (selected by the last three bits in the instruction opcode) as the operand source or destination. this mode is very efficient since an additional instruction byte is not needed to identify the operand. for example: 9.2 direct addressing this mode uses an 8-bit address, which is contained in the second byte of the instruction, to directly address an operand which resides in either 8032 data sram (internal address range 00h-07fh) or resides in 8032 sfr (internal address range 80h-ffh). this mode is quite fast since the range limit is 256 bytes of internal 8032 sram. for example: 9.3 register indirect addressing this mode uses an 8-bit address contained in either register r0 or r1 to indirectly address an operand which resides in 8032 idata sram (internal address range 80h-ffh). although 8032 sfr registers also occupy the same ph ysical address range as idata, sfrs will not be accessed by register indirect mode. sfrs may only be accesses using direct address mode. for example: mov a, r7 ; move contents of r7 to accumulator mov a, 40h ; move contents of data sram ; at location 40h into the accumulator mov a, @r0 ; move into the accumulator the ; contents of idata sram that is ; pointed to by the address ; contained in r0.
upsd34xx 8032 addressing modes 39/293 9.4 immediate addressing this mode uses 8-bits of data (a constant) contained in the second byte of the instruction, and stores it into the memory location or register indicated by the first byte of the instruction. thus, the data is immediately available within the instruction. this mode is commonly used to initialize registers and sfrs or to perform mask operations. there is also a 16-bit version of this mode fo r loading the dptr register. in this case, the two bytes following the instruction byte contain the 16-bit value. for example: 9.5 external direct addressing this mode will access external memory (xdata ) by using the 16-bit address stored in the dptr register. there are only two instructions using this mode and both use the accumulator to either receive a byte from external memory addressed by dptr or to send a byte from the accumulator to the address in dptr. the upsd34xx has a special feature to alternate the contents (source and destination) of dptr rapidly to implement very efficient memory-to-memory transfers. for example: note: see details in section 11: dual data pointers on page 47 . 9.6 external indirect addressing this mode will access external memory (xdata) by using the 8-bit addr ess stored in either register r0 or r1. this is the fastest way to access xdata (least bus cycles), but because only 8-bits are available for address, this mode limits xdata to a size of only 256 bytes (the traditional port 2 of the 8032 mcu is not availa ble in the upsd34xx, so it is not possible to write the upper address byte). for example: note: this mode is not supported by upsd34xx. 9.7 indexed addressing this mode is used for the movc instruction wh ich allows the 8032 to read a constant from program memory (not data memory). movc is often used to read look-up tables that are embedded in program memory. the final address produced by this mode is the result of mov a, 40# ; move the constant, 40h, into ; the accumulator mov dptr, 1234# ; move the constant, 1234h, into ; dptr movx a, @dptr ; move contents of accumulator to ; xdata at address contained in ; dptr movx @dptr, a ; move xdata to accumulator movx @r0,a ; move into the accumulator the ; xdata that is pointed to by ; the address contained in r0.
8032 addressing modes upsd34xx 40/293 adding either the 16-bit pc or dptr value to the contents of the accumulator. the value in the accumulator is referred to as an index. the data fetched from the final location in program memory is stored into the accumulator, overwriting the index value that was previously stored there. for example: 9.8 relative addressing this mode will add the two?s-compliment number stored in the second byte of the instruction to the program counter for short jumps within +128 or ?127 addresses relative to the program counter. this is commonly used for l ooping and is very efficient since no additional bus cycle is needed to fetch the jump destination address. for example: 9.9 absolute addressing this mode will append the 5 high-order bits of the address of the next instruction to the 11 low-order bits of an acall or ajump instruction to produce a 16-bit jump address. the jump will be within the same 2k byte page of program memory as the first byte of the following instruction. for example: 9.10 long addressing this mode will use the 16 -bits contained in the two bytes fo llowing the instruction byte as a jump destination address for lcall and ljmp instructions. for example: 9.11 bit addressing this mode allows setting or clearing an indivi dual bit without disturbing the other bits within an 8-bit value of internal sram. bit addressing is only available for certain locations in 8032 data and sfr memory. valid locations are data addresses 20h - 2fh and for sfr addresses whose base address ends with 0h or 8h. (example: the sfr, ie, has a base movc a, @a+dptr ; move code byte relative to ; dptr into accumulator movc a, @a+pc ; move code byte relative to pc ; into accumulator sjmp 34h ; jump 34h bytes ahead (in program ; memory) of the address at which ; the sjmp instruct ion is stored. if ; sjmp is at 1000h, program ; execution jumps to 1034h. ajmp 0500h ; if next instruction is located at ; address 4000h, the resulting jump ; will be made to 4500h. ljmp 0500h ; unconditionally jump to address ; 0500h in program memory
upsd34xx 8032 addressing modes 41/293 address of a8h, so each of the eight bits in ie can be addressed individually at address a8h, a9h, ...up to afh.) for example: setb afh ; set the individual ea bit (enable all ; interrupts) inside the sfr register, ; ie.
upsd34xx instruction set summary upsd34xx 42/293 10 upsd34xx instruction set summary ta bl e s 6 through 11 list all of the instructions supported by the upsd34xx, including the number of bytes and number of machine cycles required to implement each instruction. this is the standard 8051 instruction set. the meaning of ?machine cycles? is how many 8 032 mcu core machine cycles are required to execute the instruction. the ?native? duration of all machine cycles is set by the memory wait state settings in the sfr, buscon, and the mcu clock divider selections in the sfr, ccon0 (i.e. a machine cycle is typically set to 4 mcu clocks for a 5v upsd34xx). however, an individual machine cycle may grow in duration when either of two things happen: 1. a stall is imposed while loading the 8032 pre-fetch queue (pfq); or 2. the occurrence of a cache miss in the branch cache (bc) during a branch in program execution flow. see section 5: 8032 mcu core performance enhancements on page 23 or more details. but generally speaking, during typical program execution, the pfq is not empty and the bc has no misses, producing very good performance without extending the duration of any machine cycles. table 6. arithmetic instruction set mnemonic (1) and use description length/cycles add a, rn add register to acc 1 byte/1 cycle add a, direct add direct byte to acc 2 byte/1 cycle add a, @ri add indirect sram to acc 1 byte/1 cycle add a, #data add immediate da ta to acc 2 byte/1 cycle addc a, rn add register to acc with carry 1 byte/1 cycle addc a, direct add direct byte to acc with carr y 2 byte/1 cycle addc a, @ri add indirect sram to acc with carry 1 byte/1 cycle addc a, #data add immediate data to acc with carry 2 byte/1 cycle subb a, rn subtract register from acc with borrow 1 byte/1 cycle subb a, direct subtract direct byte from acc with bo rrow 2 byte/1 cycle subb a, @ri subtract indirect sram from acc with bo rrow 1 byte/1 cycle subb a, #data subtract immediate data from acc with bo rrow 2 byte/1 cycle inc a increment a 1 byte/1 cycle inc rn increment regi ster 1 byte/1 cycle inc direct increment dire ct byte 2 byte/1 cycle inc @ri increment indirect sram 1 byte/1 cycle dec a decrement ac c 1 byte/1 cycle dec rn decrement register 1 byte/1 cycle dec direct decrement direct byte 2 byte/1 cycle dec @ri decrement indire ct sram 1 byte/1 cycle
upsd34xx upsd34xx instruction set summary 43/293 note: 1 all mnemonics copyrighted ?intel corporation 1980. table 7. logical instruction set note: 1 all mnemonics copyrighted ?intel corporation 1980. inc dptr increment data pointer 1 byte/2 cycle mul ab multiply acc a nd b 1 byte/4 cycle div ab divide acc by b 1 byte/4 cycle da a decimal adjust acc 1 byte/1 cycle mnemonic (1) and use description length/cycles mnemonic (1) and use description length/cycles logical instructions anl a, rn and register to acc 1 byte/1 cycle anl a, direct and direct byte to acc 2 byte/1 cycle anl a, @ri and indirect sram to acc 1 byte/1 cycle anl a, #data and immediate da ta to acc 2 byte/1 cycle anl direct, a and acc to direct byte 2 byte/1 cycle anl direct, #data and immediate data to direct byte 3 byte/2 cycle orl a, rn or register to acc 1 byte/1 cycle orl a, direct or direct byte to acc 2 byte/1 cycle orl a, @ri or indirect sram to acc 1 byte/1 cycle orl a, #data or immediate data to acc 2 byte/1 cycle orl direct, a or acc to direct byte 2 byte/1 cycle orl direct, #data or immediate dat a to direct byte 3 byte/2 cycle swap a swap nibbles within the acc 1 byte/1 cycle xrl a, rn exclusive-or register to acc 1 byte/1 cycle xrl a, direct exclusive-or direct byte to acc 2 byte/1 cycle xrl a, @ri exclusive-or indirect sram to acc 1 byte/1 cycle xrl a, #data exclusive-or immediat e data to acc 2 byte/1 cycle xrl direct, a exclusive-or acc to direct byte 2 byte/1 cycle xrl direct, #data exclusive-or immediat e data to direct byte 3 byte/2 cycle clr a clear acc 1 byte/1 cycle cpl a compliment acc 1 byte/1 cycle rl a rotate acc le ft 1 byte/1 cycle rlc a rotate acc left through the carry 1 byte/1 cycle rr a rotate acc right 1 byte/1 cycle rrc a rotate acc right throu gh the carry 1 byte/1 cycle
upsd34xx instruction set summary upsd34xx 44/293 table 8. data transfer instruction set note: 1 all mnemonics copyrighted ?intel corporation 1980. 2 this instruction is not supported by upsd34xx. see section 9.6: external indirect addressing on page 39 mnemonic (1) and use description length/cycles mov a, rn move register to acc 1 byte/1 cycle mov a, direct move direct byte to acc 2 byte/1 cycle mov a, @ri move indirect sram to acc 1 byte/1 cycle mov a, #data move immediate da ta to acc 2 byte/1 cycle mov rn, a move acc to register 1 byte/1 cycle mov rn, direct move direct by te to register 2 byte/2 cycle mov rn, #data move immediate da ta to register 2 byte/1 cycle mov direct, a move acc to direct byte 2 byte/1 cycle mov direct, rn move register to direct byte 2 byte/2 cycle mov direct, direct move direct byte to direct 3 byte/2 cycle mov direct, @ri move indirect sram to direct byte 2 byte/2 cycle mov direct, #data move immediate da ta to direct byte 3 byte/2 cycle mov @ri, a move acc to i ndirect sram 1 byte/1 cycle mov @ri, direct move direct byte to indirect sram 2 byte/2 cycle mov @ri, #data move imme diate data to indire ct sram 2 byte/1 cycle mov dptr, #data16 load data pointer with 16-b it constant 3 byte/2 cycle movc a, @a+dptr move code byte relative to dptr to acc 1 byte/2 cycle movc a, @a+pc move code byte relative to pc to acc 1 byte/2 cycle movx a, @ri (2) move xdata (8-bit addr) to acc 1 byte/2 cycle movx a, @dptr move xdata (16-bi t addr) to acc 1 byte/2 cycle movx @ri, a (2) move acc to xdata (8-bit addr) 1 byte/2 cycle movx @dptr, a move acc to xdat a (16-bit addr) 1 byte/2 cycle xch a, rn exchange register with acc 1 byte/1 cycle push direct push direct byte onto stack 2 byte/2 cycle pop direct pop direct byte from stack 2 byte/2 cycle xch a, direct exchange direct by te with acc 2 byte/1 cycle xch a, @ri exchange indirect sr am with acc 1 byte/1 cycle xchd a, @ri exchange low-order digit indirect sram with acc 1 byte/1 cycle
upsd34xx upsd34xx instruction set summary 45/293 table 9. boolean variable ma nipulation instruction set note: 1 all mnemonics copyrighted ?intel corporation 1980. table 10. program branching instruction set mnemonic (1) and use description length/cycles clr c clear carry 1 byte/1 cycle clr bit clear direct bit 2 byte/1 cycle setb c set carry 1 byte/1 cycle setb bit set direct bit 2 byte/1 cycle cpl c compliment carry 1 byte/1 cycle cpl bit compliment direct bit 2 byte/1 cycle anl c, bit and direct bit to carry 2 byte/2 cycle anl c, /bit and compliment of dire ct bit to carry 2 byte/2 cycle orl c, bit or direct bit to carry 2 byte/2 cycle orl c, /bit or compliment of dire ct bit to carr y 2 byte/2 cycle mov c, bit move direct bit to carry 2 byte/1 cycle mov bit, c move carry to direct bit 2 byte/2 cycle jc rel jump if carry is set 2 byte/2 cycle jnc rel jump if carry is not set 2 byte/2 cycle jb rel jump if direct bi t is set 3 byte/2 cycle jnb rel jump if direct bit is not set 3 byte/2 cycle jbc bit, rel jump if direct bit is set and clear bit 3 byte/2 cycle mnemonic (1) and use description length/cycles program branching instructions acall addr11 absolute subroutine call 2 byte/2 cycle lcall addr16 long subroutine call 3 byte/2 cycle ret return from subroutine 1 byte/2 cycle reti return from interrupt 1 byte/2 cycle ajmp addr11 absolute jump 2 byte/2 cycle ljmp addr16 long jump 3 byte/2 cycle sjmp rel short jump (relative addr) 2 byte/2 cycle jmp @a+dptr jump indirect relati ve to the dptr 1 byte/2 cycle jz rel jump if acc is zero 2 byte/2 cycle jnz rel jump if acc is not zero 2 byte/2 cycle cjne a, direct, rel compare direct byte to acc, jump if not equal 3 byte/2 cycle cjne a, #data, rel compare immediate to acc, jump if not equal 3 byte/2 cycle cjne rn, #data, rel compare immediate to register, jump if not equal 3 byte/2 cycle
upsd34xx instruction set summary upsd34xx 46/293 note: 1 all mnemonics copyrighted ?intel corporation 1980. table 11. miscellaneous instruction set note: 1 all mnemonics copyrighted ?intel corporation 1980. table 12. notes on instruction set and addressing modes cjne @ri, #data, rel compare immediate to indirect, ju mp if not equal 3 byte/2 cycle djnz rn, rel decrement register and jump if not zero 2 byte/2 cycle djnz direct, rel decrement direct byte and jump if not zero 3 byte/2 cycle mnemonic (1) and use description length/cycles mnemonic (1) and use description length/cycles miscellaneous nop no operation 1 byte/1 cycle rn register r0 - r7 of the currently selected register bank. direct 8-bit address for internal 8032 data sram (locations 00h - 7fh) or sfr registers (locations 80h - ffh). @ri 8-bit internal 8032 sram (locations 00h - ff h) addressed indirectly through contents of r0 or r1. #data 8-bit constant incl uded within the instruction. #data16 16-bit constant inclu ded within the instruction. addr16 16-bit destination address used by lcall and ljmp. addr11 11-bit destination address used by acall and ajmp. rel signed (two-s compliment) 8-bit offset byte. bit direct addressed bit in internal 8032 data sram (locations 20h to 2fh) or in sfr registers (88h, 90h, 98h, a8h, b0, b8h, c0h, c8h, d0h, d8h, e0h, f0h).
upsd34xx dual data pointers 47/293 11 dual data pointers xdata is accessed by the external direct a ddressing mode, which uses a 16-bit address stored in the dptr register. traditional 8032 architecture has only one dptr register. this is a burden when transferring data between two xdata locations because it requires heavy use of the working registers to manipulate the source and destination pointers. however, the upsd34xx has two data pointers, one for storing a source address and the other for storing a destination address. these pointers can be configured to automatically increment or decrement after each data transfer, further reducing the burden on the 8032 and making this kind of data movement very efficient. 11.1 data pointer contro l register, dptc (85h) by default, the dptr register of the upsd34 xx will behave no different than in a standard 8032 mcu. the dpsel0 bit of sfr register dptc shown in ta b l e 1 3 , selects which one of the two ?background? data po inter registers (dptr0 or dptr1) will function as the traditional dptr register at any given time. after reset, the dpsel0 bit is cleared, enabling dptr0 to function as the dptr, and firmware may access dptr0 by reading or writing the traditional dptr register at sfr addresses 82h and 83h. when the dpsel0 bit is set, then the dptr1 register functions as dptr, and firmware may now access dptr1 through sfr registers at 82h and 83h. the pointer which is not selected by the dpsel0 bit remains in the background and is not accessible by the 8032. if the dpsel0 bit is never set, then the upsd34xx will behave like a traditi onal 8032 having only one dptr register. to further speed xdata to xdata transfers, the sfr bit, at, may be set to automatically toggle the two data pointers, dptr0 and dptr1, each time the standard dptr register is accessed by a movx instruction. this eliminates the need for firmware to manually manipulate the dpsel0 bit between each data transfer. detailed description for the sfr register dptc is shown in ta b l e 1 3 . table 13. dptc: data pointer control register (sfr 85h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? at ? ? ? ? ? dpsel0 bit symbol r/w definition 7 ? ? reserved 6atr,w 0 = manually select data pointer 1 = auto toggle between dptr0 and dptr1 5-1 ? ? reserved 0 dpse0 r,w 0 = dptr0 selected for use as dptr 1 = dptr1 selected for use as dptr
dual data pointers upsd34xx 48/293 11.2 data pointer mode register, dptm (86h) the two ?background? data pointers, dptr0 and dptr1, can be configured to automatically increment, decrement, or stay the same after a movx instruction accesses the dptr register. only the currently selected pointer will be affected by the increment or decrement. this feature is controlled by the dptm register defined in ta bl e 1 4 . the automatic increment or decrement function is effective only for the movx instruction, and not movc or any other instruction that uses the dtpr register. 11.2.1 firmware example the 8051 assembly code illustrated in ta bl e 1 5 shows how to transfer a block of data bytes from one xdata address region to another xdata address region. auto-address incrementing and auto-poi nter toggling will be used. table 14. dptm: data pointer mode register (sfr 86h, reset value 00h) table 15. 8051 assembly code example bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? md11 md10 md01 md00 bit symbol r/w definition 7-4 ? ? reserved 3-2 md[11:10] r,w dptr1 mode bits 00: dptr1 no change 01: reserved 10: auto increment 11: auto decrement 1-0 md[01:00] r,w dptr0 mode bits 00: dptr0 no change 01: reserved 10: auto increment 11: auto decrement mov r7, #count ; initialize size of data block to transfer mov dptr, #source_addr ; load xdata source address base into dptr0 mov 85h, #01h ; load dptc to access dptr1 pointer mov dptr, #dest_addr ; load xdata destination address base into dptr1 mov 85h, #40h ; load dptc to access dptr0 pointer and auto toggle mov 86h, #0ah ; load dptm to auto-increment both pointers
upsd34xx dual data pointers 49/293 note: 1 the code loop where the data transfer takes place is only 3 lines of code. loop: movx (1) a, @dptr ; load xdata byte from source into acc. ; after load completes, dptr0 increments and dptr ; switches dptr1 movx (1) @dptr, a ; store xdata byte from acc to destination. ; after store completes, dptr1 increments and dptr ; switches to dptr0 djnz (1) r7, loop ; continue until done mov 86h, #00 ; disable auto-increment mov 85h, #00 ; disable auto-toggle, now back to single dptr mode
debug unit upsd34xx 50/293 12 debug unit the 8032 mcu module supports run-time debugging through the jtag interface. this same jtag interface is also used for in-system programming (isp) and the physical connections are described in the psd module section, section 28.6.1: jtag isp and jtag debug on page 251 . debugging with a serial interface such as jtag is a non-intrusive way to gain access to the internal state of the 8032 mcu core and various memories. a traditional external hardware emulator cannot be completely effective on the upsd34xx because of the pre-fetch queue and branch cache. the nature of the pfq and bc hide the visibility of actual program flow through traditional external bus connections, thus requiring on-chip serial debugging instead. debugging is supported by windows pc based software tools used for 8051 code development from 3rd party v endors listed at www.st.com/p sm. debug capabilities include: halt or start mcu execution reset the mcu single step 3 match breakpoints 1 range breakpoint (inside or outside range) program tracing read or modify mcu core registers, data, idata, sfr, xdata, and code external debug event pin, input or output some key points regarding use of the jtag debugger. ? the jtag debugger can access mcu registers, data memory, and code memory while the mcu is executing at full speed by cycle-stealing. this means ?watch windows? may be displayed and periodically updated on the pc during full speed operation. registers and data content may also be modified during full speed operation. ? there is no on-chip storage for program trace data, but instead this data is scanned from the upsd34xx through the jtag channel at run-time to the pc host for proccessing. as such, full speed program tracing is possible only when the 8032 mcu is operating below approximately one mips of performance. above one mips, the program will not run real-tim e while tracing. one mips performance is determined by the combination of choice for mcu clock frequency, and the bit settings in sfr regist ers buscon and ccon0. ? breakpoints can optionally halt the mcu, and/or assert the external debug event pin. ? breakpoint definitions may be qualified with read or write operations, and may also be qualified with an address of code, sfr, data, idata, or xdata memories. ? three breakpoints will compare an address, but the fourth breakpoint can compare an address and also data content. additionally, the fouth breakpoint can be logically combined (and/or) with any of the other three breakpoints. ? the debug event pin can be configured by the pc host to generate an output pulse for external triggering when a break condition is met. the pin can also be configured as an event inpu t to the breakpoint logic, causing a break on the falling- edge of an external event signal. if not used, the debug event pin should be pulled
upsd34xx debug unit 51/293 up to v cc as described in the section, section 28.6.8: debugging the 8032 mcu module on page 257 . ? the duration of a pulse, generated when the event pin configured as an output, is one mcu clock cycle. this is an active-low signal, so the first edge when an event occurs is high-to-low. ? the clock to the watchdog timer, adc, and i 2 c interface are not stopped by a breakpoint halt. ? the watchdog timer should be disabled while debugging with jtag, else a reset will be generated upon a watchdog time-out.
interrupt system upsd34xx 52/293 13 interrupt system the upsd34xx has an 12-source, two priority level interrupt structure summarized in ta bl e 1 6 . firmware may assign each interrupt source either high or low priority by writing to bits in the sfrs named, ip and ipa, shown in ta b l e 1 6 . an interrupt will be serviced as long as an interrupt of equal or higher priority is not already being serviced. if an interrupt of equal or higher priority is being serviced, the new interrupt will wait unt il it is finished before being serviced. if a lower priority interrupt is be ing serviced, it will be stopped and the new interrupt is serviced. when the new interrupt is finished, the lower priority interrupt that was stopped will be completed. if new interrupt requests ar e of the same priority level and are received simultaneously, an inte rnal polling sequence determine s which request is selected for service. thus, within each of the two priority levels, there is a second priority structure determined by the polling sequence. firmware may individually enable or disable inte rrupt sources by writing to bits in the sfrs named, ie and iea, shown in table 16 on page 53 . the sfr named ie contains a global disable bit (ea), which can be cleared to disable all 12 interrupts at once, as shown in table 17 on page 56 . figure 13 on page 54 illustrates the interrupt priority, polling, and enabling process. each interrupt source has at least one interrupt flag that indicates whether or not an interrupt is pending. these flags reside in bits of various sfrs shown in table 16 on page 53 . all of the interrupt flags are latched into the interrupt control system at the beginning of each mcu machine cycle, and they are polled at the beginning of the following machine cycle. if polling determines one of the flags was set, the interrupt control system automatically generates an lcall to the user?s interrupt service routine (isr) firmware stored in program memory at the appropriate vector address. the specific vector address for each of the interrupt sources are listed in table 16 on page 53 . however, this lcall jump may be blocked by any of the following conditions: an interrupt of equal or higher priority is already in progress the current machine cycle is not the final cycle in the execution of the instruction in progress the current instruction involves a write to any of the sfrs: ie, iea, ip, or ipa the current instruction is an reti note: interrupt flags are polled based on a sample taken in the previous mcu machine cycle. if an interrupt flag is active in one cycle but is denied serviced due to the conditions above, and then later it is not active when the conditions above are finally satisfied, the previously denied interrupt will not be serv iced. this means that active interrupts are not remembered. every poling cycle is new. assuming all of the listed conditions are satisfied, the mcu executes the hardware generated lcall to the appropriate isr. this lcall pushes the contents of the pc onto the stack (but it does not save the psw) and loads the pc with the appropriate interrupt vector address. program execution then jumps to the isr at the vector address. execution precedes in the isr. it may be necessary for the isr firmware to clear the pending interrupt flag for some interrupt sources, because not all interrupt flags are automatically cleared by hardware when the isr is called, as shown in table 16 on page 53 .
upsd34xx interrupt system 53/293 if an interrupt flag is not cleared after servic ing the interrupt, an un wanted interrupt will occur upon exiting the isr. after the interrupt is serviced, the last instru ction executed by the isr is reti. the reti informs the mcu that the isr is no longer in progress and the mcu pops the top two bytes from the stack and loads them into the pc. execution of the interrupted program continues where it left off. note: an isr must end with a reti instruction, not a ret. an ret will not inform the interrupt control system that the isr is complete, leaving the mcu to thin k the isr is still in progress, making future interrupts impossible. table 16. interrupt summary interrupt source polling priority vecto r addr flag bit name (sfr.bit position) 1 = intr pending 0 = no interrupt flag bit auto- cleared by hardware? enable bit name (sfr.bit position) 1 = intr enabled 0 = intr disabled priority bit name (sfr.bit position) 1= high priority 0 = low priority reserved 0 (high) 0063h ? ? ? ? external interrupt int0 1 0003h ie0 (tcon.1) edge - yes level - no ex0 (ie.0) px0 (ip.0) timer 0 overflow 2 000bh tf0 (tcon.5) yes e t0 (ie.1) pt0 (ip.1) external interrupt int1 3 0013h ie1 (tcon.3 edge - yes level - no ex1 (ie.2) px1 (ip.2) timer 1 overflow 4 001bh tf1 (tcon.7) yes e t1 (ie.3) pt1 (ip.3) uart0 5 0023h ri (scon0.0) ti (scon0.1) no es0 (ie.4) ps0 (ip.4) timer 2 overflow or tx2 pin 6 002bh tf2 (t2con.7) exf2 (t2con.6) no et2 (ie.5) pt2 (ip.5) spi 7 0053h teisf, rorisf, tisf, risf (spistat[3:0]) yes espi (iea.6) pspi (ipa.6) usb 8 0033h ? (1) no eusb (iea.0) pusb (ipa.0) i 2 c 9 0043h intr (s1sta.5) yes ei 2 c (iea.1) pi 2 c (ipa.1) adc 10 003bh aintf (acon.7) no eadc (iea.7) padc (ipa.7)
interrupt system upsd34xx 54/293 note: 1 see usb interrupt flag registers uif0-3. figure 13. enabling and polling interrupts pca 11 005bh ofvx, intfx (pcasta[0:7]) no epca (iea.5) ppca (ipa.5) uart1 12 (low) 004bh ri (scon1.0) ti (scon1.1) no es1 (iea.4) ps1 (ipa.4) interrupt source polling priority vecto r addr flag bit name (sfr.bit position) 1 = intr pending 0 = no interrupt flag bit auto- cleared by hardware? enable bit name (sfr.bit position) 1 = intr enabled 0 = intr disabled priority bit name (sfr.bit position) 1= high priority 0 = low priority reserved ext int0 ext int1 timer 0 uart0 timer 1 spi usb timer 2 high low interrupt polling sequence interrupt sources ie/iea ip/ipa priority global enable adc pca i 2 c uart1 ai07844
upsd34xx interrupt system 55/293 13.1 individual interrupt sources 13.1.1 external interrupts int0 and int1 external interrupt inputs on pins extint0 and extint1 (pins 3.2 and 3.3) are either edge- triggered or level-triggered, depending on bits it0 and it1 in the sfr named tcon. when an external interrupt is generated from an edge-triggered (falling-edge) source, the appropriate flag bit (ie0 or ie1) is automatic ally cleared by hardware upon entering the isr. when an external interrupt is generated from a level-triggered (low-level) source, the appropriate flag bit (ie0 or ie1) is not automatically cleared by hardware. 13.1.2 timer 0 and 1 overflow interrupt timer 0 and timer 1 interrupts are generated by the flag bits tf0 and tf1 when there is an overflow condition in the respective timer/counter register (except for timer 0 in mode 3). 13.1.3 timer 2 overflow interrupt this interrupt is generated to the mcu by a logical or of flag bits, tf2 and exe2. the isr must read the flag bits to determine the cause of the interrupt. tf2 is set by an overflow of timer 2. exe2 is generated by the falling edge of a si gnal on the external pin, t2x (pin p1.1). 13.1.4 uart0 and uart1 interrupt each of the uarts have identical interrupt structure. for each uart, a single interrupt is generated to the mcu by the logical or of the flag bits, ri (byte received) and ti (byte transmitted). the isr must read flag bits in the sfr named scon0 for uart0, or scon1 for uart1 to determine the cause of the interrupt. 13.1.5 spi interrupt the spi interrupt has four interrupt sources, which are logically ored together when interrupting the mcu. the isr must read the flag bits to determine the cause of the interrupt. a flag bit is set for: end of data transmit (teisf); data receive overrun (rorisf); transmit buffer empty (tisf); or receive buffer full (risf). 13.1.6 i 2 c interrupt the flag bit intr is set by a variety of conditions occurring on the i 2 c interface: received own slave address (addr flag); received gene ral call address (gc fl ag); received stop condition (stop flag); or successful transmission or reception of a data byte.the isr must read the flag bits to determine the cause of the interrupt. 13.1.7 adc interrupt the flag bit aintf is set when an a-to-d conversion has completed.
interrupt system upsd34xx 56/293 13.1.8 pca interrupt the pca has eight interrupt sources, which are logically ored together when interrupting the mcu.the isr must read the flag bits to determine the cause of the interrupt. each of the six tcms can generate a "match or capture" interrupt on flag bits ofv5..0 respectively. each of the two 16-bit counters can generate an overflow interrupt on flag bits intf1 and intf0 respectively. ta bl e s 17 through table 20 on page 58 have detailed bit definitions of the interrupt system sfrs. 13.1.9 usb interrupt the usb interrupt has multiple sources. the isr must read the usb interrupt flag registers (uif0-3) to determine the source of the interrupt. the usb interrupt can be activated by any of the following four group of interrupt sources: global: the interrupt flag is set when any of the following events occurs: usb reset, usb suspend, usb resume, and end of packet; in fifo: the interrupt flag is set when any of the end point in fifo becomes empty; out fifo: the interrupt flag is set when any of the end point out fifo becomes full; and in fifo nak: the interrupt flag is set when any of the end point in fifo is not ready for an in (in-bound) packet. table 17. ie: interrupt enable register (sfr a8h, reset value 00h) note: 1 1 = enable interrupt, 0 = disable interrupt bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ea ? et2 es0 et1 ex1 et0 ex0 bit symbol r/w function 7ear,w global disable bit. 0 = all interrupts are disabled. 1 = each interrupt source can be individually enabled or disabled by setting or clearing its enable bit. 6?r,w do not modify this bit. it is us ed by the jtag debugger for instruction tracing. always read the bit and write back the same bit value when writing this sfr. 5 (1) et2 r,w enable timer 2 interrupt 4 (1) es0 r,w enable uart0 interrupt 3 (1) et1 r,w enable timer 1 interrupt 2 (1) ex1 r,w enable external interrupt int1 1 (1) et0 r,w enable timer 0 interrupt 0 (1) ex0 r,w enable external interrupt int0
upsd34xx interrupt system 57/293 table 18. iea: interrupt enable addition register (sfr a7h, reset value 00h) note: 1 1 = enable interrupt, 0 = disable interrupt table 19. ip: interrupt priority register (sfr b8h, reset value 00h) note: 1 1 = assigns high priority level, 0 = assigns low priority level bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 eadc espi epca es1 ? ? ei 2 ceusb bit symbol r/w function 7 (1) eadc r,w enable adc interrupt 6 (1) espi r,w enable spi interrupt 5 (1) epca r,w enable programmable counter array interrupt 4 (1) es1 r,w enable uart1 interrupt 3 ? ? reserved, do not set to logic '1.' 2 ? ? reserved, do not set to logic '1.' 1 (1) ei 2 cr,wenable i 2 c interrupt 0 eusb r,w enable usb interrupt bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? pt2 ps0 pt1 px1 pt0 px0 bit symbol r/w function 7 ? ? reserved 6 ? ? reserved 5 (1) pt2 r,w timer 2 interrupt priority level 4 (1) ps0 r,w uart0 interrupt priority level 3 (1) pt1 r,w timer 1 interrupt priority level 2 (1) px1 r,w external interrupt int1 priority level 1 (1) pt0 r,w timer 0 interrupt priority level 0 (1) px0 r,w external interrupt int0 priority level
interrupt system upsd34xx 58/293 table 20. ipa: interrupt priority addition register (sfr b7h, reset value 00h) note: 1 1 = assigns high priority level, 0 = assigns low priority level bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 padc pspi ppca ps1 ? ? pi 2 cpusb bit symbol r/w function 7 (1) padc r,w adc interrupt priority level 6 (1) pspi r,w spi interrupt priority level 5 (1) ppca r,w pca interrupt level 4 (1) ps1 r,w uart1 interrupt priority level 3 ? ? reserved 2 ? ? reserved 1 (1) pi 2 cr,wi 2 c interrupt priority level 0 pusb r,w usb interrupt priority level
upsd34xx mcu clock generation 59/293 14 mcu clock generation internal system clocks generated by the clock generation unit are derived from the signal, xtal1, shown in figure 14 . xtal1 has a frequency f osc , which comes directly from the external crystal or oscillator device. the sfr named ccon0 ( table 22 on page 62 ) controls the clock generation unit. there are two clock signals produced by the clock generation unit: mcu_clk periph_clk 14.1 mcu_clk this clock drives the 8032 mcu core and the watchdog timer (wdt). the frequency of mcu_clk is equal to f osc by default, but it can be divided by as much as 2048, shown in figure 14 . the bits cpups[2:0] select one of eight different divisors, ranging from 2 to 2048. the new frequency is available immediately after the cpups[2:0] bits are written. the final frequency of mcu_clk is f mcu . mcu_clk is blocked by either bit, pd or idl, in the sfr named pcon during mcu power- down mode or idle mode respectively. mcu_clk clock can be further divided as required for use in the wdt. see details of the wdt in section 19: supervisory functions on page 83 . 14.2 periph_clk this clock drives all the upsd34xx peripherals except the wdt. the frequency of periph_clk is always f osc . each of the peripherals can independently divide periph_clk to scale it appropriately for use. periph_clk runs at all times except when blocked by the pd bit in the sfr named pcon during mcu power-down mode. 14.2.1 jtag interface clock the jtag interface for isp and for debugging uses the externally supplied jtag clock, coming in on pin tck. this means the jtag isp interface is always available, and the jtag debug interface is available when enabled, even during mcu idle mode and power-down mode. however, since the mcu participates in the jtag debug process, and mcu_clk is halted during idle and power-down modes, the majority of debug functions are not available during these low power modes. but the jtag debug interface is capable of executing a reset command while in these low power modes, wh ich will exit back to normal operating mode where all debug commands are available again. the ccon0 sfr contains a bit, dbgce, whic h enables the breakpoint comparators inside the jtag debug unit when set. dbgce is set by default after reset, and firmware may clear this bit at run-time. disabling these comparators will reduce current consumption on the mcu module, and it is recommended to do so if the debug unit will not be used (such as in the production version of an end-product).
mcu clock generation upsd34xx 60/293 14.2.2 usb_clk the upsd34xx has a dedicated analog phase lo cked loop (pll) that can be configured to generate the 48mhz usb_clk clock on a wide range of f osc frequencies. the usb_clk must be at 48mhz for the usb to function properly. the pll is enabled after power up. the power on lock time for the pll clock is about 200s, and the firmware should wait that much time before enabling the usb_clk by setting the upllce bit in the ccon0 register to '1.' the pll is disabled in power-down mode, it can also be disabled or enabled by writing to the pllen bit in the ccon0 register. the pll output clock frequency (f usb_clk ) can be determined by using the following formula: where pllm and plld are the multiplier and divisor that are specified in the ccon1 register. the f osc , the pllm and plld range must meet the following conditions to generate a stable usb_clk: a) ?1 pllm 30 (binary: [11111] pllm[4:0] [11110]), b) ?1 plld 14 (binary: [1111] plld[3:0] [1110]), and c) f osc /(plld+2) must be equal to or greater than 3mhz. the usb requires a 48mhz clock to operate corr ectly. the pllm[4:0] and plld[3:0] values must be selected so as to generate a usb_clk that is as close to 48mhz as possible at different oscillator frequencies (f osc ). ta b l e 2 1 lists some of the pllm and plld values that can be used on common f osc frequencies. table 21. pllm and plld values for different f osc frequencies f osc (mhz) pllm[4:0] plld[3:0] f usb_clk (mhz) decimal binary decimal binary 40.0 22 10110 8 1000 48.0 36.0 6 00110 1 0001 48.0 33.0 30 11110 9 1001 48.0 30.0 14 01110 3 0011 48.0 24.0 18 10010 3 0011 48.0 16.0 28 11100 3 0011 48.0 12.0 30 11110 2 0010 48.0 8.0 22 10110 0 0000 48.0 6.0 30 11110 0 0000 48.0 3.0 30 11110 ?1 1111 48.0 f usbclk f osc pllm 2 + () [] plld 2 + () 2 [] ? =
upsd34xx mcu clock generation 61/293 figure 14. clock generation logic xtal1 /2 xtal1 /4 xtal1 /2048 q q q m u x xtal1 (default) xtal1 /8 xtal1 /16 q q xtal1 /32 xtal1 /1024 q q 0 1 2 3 4 5 6 7 clk pll en xtal1 (f osc ) pcon[1] ccon0[6] pcon[1]: pd, power-down mode ccon[2:0], clock pre-scaler select pcon[0]: idl, idle mode clock divider mcu_clk (f mcu ) (to: 8032, wdt) periph_clk (f osc ) (to: timer0/1/2, uart0/1, pca0/1, spi, i2c, adc) usb_clk 3 ai10433b
mcu clock generation upsd34xx 62/293 table 22. ccon0: clock control register (sfr f9h, reset value 50h) table 23. ccon1 pll control register (sfr fah, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pllm[4] pllen upllce dbgce cpuar cpups[2:0] bit symbol r/w definition 7 pllm[4] r,w upper bit of the 5-bit pllm[4:0] multiplier (default: '0' for pllm = 00h) 6 pllen r,w pll enable 0 = disable pll operation 1 = enable pll operation (default condition after reset) 5 upllce r,w usb clock enable 0 = usb clock is disabled (default condition after reset) 1 = usb clock is enabled 4dbgcer,w debug unit breakpoint comparator enable 0 = jtag debug unit comparators are disabled 1 = jtag debug unit comparators are enabled (default condition after reset) 3 cpuar r,w automatic mcu clock recovery 0 = there is no change of cpups[2:0] when an interrupt occurs. 1 = contents of cpups[2:0] automatically become 000b whenever any interrupt occurs. 2:0 cpups r,w mcuclk pre-scaler 000b: f mcu = f osc (default after reset) 001b: f mcu = f osc /2 010b: f mcu = f osc /4 011b: f mcu = f osc /8 100b: f mcu = f osc /16 101b: f mcu = f osc /32 110b: f mcu = f osc /1024 111b: f mcu = f osc /2048 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pllm[3:0] plld[3:0] bit symbol r/w definition 7:4 pllm[3:0] r,w lower 4 bits of the 5-bit pllm[4:0] multiplier (default after reset: pllm = 00h) pllm[4] is in the ccon0 register. 3:0 plld[3:0] r,w 4-bit pll divider (default after reset: plld = 0h)
upsd34xx power saving modes 63/293 15 power saving modes the upsd34xx is a combination of two die, or modules, each module having its own current consumption characteristics. this section describes reduced power modes for the mcu module. see section 28.1.16: power management on page 191 for reduced power modes of the psd module. total current consumption for the combined modules is determined in the dc specifications at the end of this document. the mcu module has three software-selectable modes of reduced power operation. idle mode power-down mode reduced frequency mode 15.1 idle mode idle mode will halt the 8032 mcu core while leaving the mcu peripherals active (idle mode blocks mcu_clk only). for lowest current consumption in this mode, it is recommended to disable all unused peripherals, before entering idle mode (such as the adc and the debug unit breakpoint comparators). th e following functions re main fully active during idle mode (except if disabled by sfr settings). external interrupts int0 and int1 timer 0, timer 1 and timer 2 supervisor reset from: lvd, jtag debug, external reset_in_, but not the wtd adc i 2 c interface uart0 and uart1 interfaces spi interface programmable counter array usb interface an interrupt generated by any of these peripherals, or a reset generated from the supervisor, will cause idle mode to exit and the 8032 mcu will resu me normal operation. the output state on i/o pins of mcu ports 1, 3, and 4 remain unchanged during idle mode. to enter idle mode, the 8032 mcu executes an instruction to set the idl bit in the sfr named pcon, shown in table 26 on page 66 . this is the last instru ction executed in normal operating mode before idle mode is activated. once in idle mode, the mcu status is entirely preserved, and there are no changes to: sp, psw, pc, acc, sfrs, data, idata, or xdata. the following are factors related to idle mode exit: activation of any enabled interrupt will caus e the idl bit to be cleared by hardware, terminating idle mode. the interrupt is serviced, and following the return from interrupt instruction (reti), the next in struction to be executed will be the one which follows the instruction that set the idl bit in the pcon sfr. after a reset from the supervisor, the idl bit is cleared, idle mode is terminated, and the mcu restarts after three mcu machine cycles.
power saving modes upsd34xx 64/293 15.2 power-down mode power-down mode will halt t he 8032 core and all mcu pe ripherals (power-down mode blocks mcu_clk, usb_clk, and periph_clk). this is the lowest power state for the mcu module. when the psd module is also pl aced in power-down mode, the lowest total current consumption for the combined die is achieved for the upsd34xx. see section 28.1.16: power management on page 191 in the psd module section for details on how to also place the psd module in power-down mode. the sequence of 8032 instructions is important when placing both modules into power-down mode. the instruction that sets the pd bit in the sfr named pcon ( table 26 on page 66 ) is the last instruction executed prior to the mcu mo dule going into power-down mode. once in power-down mode, the on-chip oscillator circui try and all clocks ar e stopped. the sfrs, data, idata, and xdata are preserved. power-down mode is terminated only by a reset from the supervisor, originating from the reset_in_ pin, the low-voltag e detect circuit (lvd), or a jtag debug reset command. since the clock to the wtd is not active during power-down mode, it is not possible for the supervisor to generate a wdt reset. table 24 on page 65 summarizes the status of i/o pins and peripherals during idle and power-down modes on the mcu module. table 25 on page 65 shows the state of 8032 mcu address, data, and control signals during these modes. 15.3 reduced frequency mode the 8032 mcu consumes less current when operating at a lower clock frequency. the mcu can reduce its own clock frequency at run-time by writing to three bits, cpups[2:0], in the sfr named ccon0 described in table 22 on page 62 . these bits effectively divide the clock frequency (f osc ) coming in from the external cryst al or oscillator device. the clock division range is from 1/2 to 1/2048, and the resulting frequency is f mcu . this mcu clock division does not affect any of the peripherals, except for the wtd. the clock driving the wtd is the same clock driving the 8032 mcu core as shown in figure 14 on page 61 . mcu firmware may reduce the mcu clock frequency at run-time to consume less current when performing tasks that are not time critical, and then restore full clock frequency as required to perform urgent tasks. returning to full clock frequency is done automatically upon an mcu interrupt, if the cpuar bit in the sfr named ccon0 is set (the interrupt will force cp ups[2:0] = 000). this is an excellent way to conserve power using a low frequency clock until an event occurs that requires full performance. see table 22 on page 62 for details on cpuar. see the dc specifications at the end of this document to estimate current consumption based on the mcu clock frequency. note: some of the bits in the pcon sfr shown in table 26 on page 66 are not related to power control.
upsd34xx power saving modes 65/293 table 24. mcu module port and peripheral status during reduced power modes note: 1 the watchdog timer is not active during id le mode. other supervisor functions are active: lvd, external reset, jtag debug reset. table 25. state of 8032 mcu bus signals during power-down and idle modes mode ports 1, 3, 4 spi, i 2 c, uart0,1 pca, timer 0,1,2 usb adc ext int0,1 super- visory idle maintain data active active active active active active (1) power- down maintain data disabled disabled disabled disabled disabled disabled mode ale psen_ rd_ wr_ ad0-7 a8-15 idle 0 1 1 1 ffh ffh power-down 0 1 1 1 ffh ffh
power saving modes upsd34xx 66/293 table 26. pcon: power control register (sfr 87h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 smod0 smod1 ? por rclk1 tclk1 pd idl bit symbol r/w function 7 smod0 r,w baud rate double bit (uart0) 0 = no doubling 1 = doubling (see section 21.3: uart baud rates on page 102 for details.) 6 smod1 r,w baud rate double bit for 2nd uart (uart1) 0 = no doubling 1 = doubling (see section 21.3: uart baud rates on page 102 for details.) 5 ? ? reserved 4porr,w only a power-on reset sets this bit (cold reset). warm reset will not set this bit. 0 = cleared to zero with firmware 1 = is set only by a power-on reset generated by supervisory circuit (see section 19.3: power-up reset on page 84 for details). 3 rclk1 r,w received clock flag (uart1) (see table 43 on page 93 for flag description.) 2 tclk1 r,w transmit clock flag (uart1) (see table 43 on page 93 for flag description) 1pdr,w activate power-down mode 0 = not in power-down mode 1 = enter power-down mode 0 idl r,w activate idle mode 0 = not in idle mode 1 = enter idle mode
upsd34xx oscillator and external components 67/293 16 oscillator and external components the oscillator circuit of upsd34xx devices is a single stage, inverting amplifier in a pierce oscillator configuration. the internal circuitry between pins xtal1 and xtal2 is basically an inverter biased to the transfer point. either an external quartz crystal or ceramic resonator can be used as the feedback element to complete the oscillator circuit. both are operated in parallel resonance. ceramic resonators are lower cost, but typically have a wider frequency tolerance than quartz crystals. alternatively, an external clock source from an oscillator or other active device may drive the upsd34xx osc illator circuit input directly, instead of using a crystal or resonator. the minimum frequency of the quartz crystal, ceramic resonator, or external clock source is 3mhz if the usb is used. the minimum is 8mhz if i 2 c is used. the maximum is 40mhz in all cases. this frequency is f osc , which can be divided internally as described in section 14: mcu clock generation on page 59 . the pin xtal1 is the high gain amplifier input, and xtal2 is the output. to drive the upsd34xx device externally fr om an oscillator or other active device, xtal1 is driven and xtal2 is left open-circuit. this external source should drive a logic low at the voltage level of 0.3 v cc or below, and logic high at 0.7v v cc or above, up to 5.5v v cc . the xtal1 input is 5v tolerant. most of the quartz crystals in the range of 25mhz to 40mhz operate in the third overtone frequency mode. an external lc tank circuit at the xtal2 output of th e oscillator circuit is needed to achieve the third overtone frequency, as shown in figure 15 on page 68 . without this lc circuit, the crystal will oscillate at a fu ndamental frequency mode that is ab out 1/3 of the desired overtone frequency. note: in figure 15 on page 68 crystals which are specified to operate in fundamental mode (not overtone mode) do not need the lc circuit components. since quartz crystals and ceramic resonators have their own characteristics based on their manufacturer, it is wise to also consult the manufacturer?s recommended values for external components.
oscillator and external components upsd34xx 68/293 figure 15. oscillator and clock connections crystal or resonator usage direct drive xtal1 (in) xtal1 (in) xtal2 (out) xtal2 (out) c1 c2 xtal (f osc ) l1 c3 no connect external ocsillator or active clock source xtal (f osc ) c1 = c2 c3 l1 ceramic resonator 40 - 50pf none crystal, fundamental mode (3-40mhz) 15-33pf none none none crystal, overtone mode (25-40mhz) 20pf 10nf 2.2h ai09198
upsd34xx i/o ports of mcu module 69/293 17 i/o ports of mcu module the mcu module has three 8-bit i/o ports: port 1, port 3, and port 4. the psd module has four other i/o ports: port a, b, c, and d. this section describes only the i/o ports on the mcu module. i/o ports will function as bi-directional genera l purpose i/o (gpio), but the port pins can have alternate functions assigned at run-time by writing to specific sfrs. the default operating mode (during and after reset) for all three ports is gpio input mode. port pins that have no external connection will not float because ea ch pin has an internal weak pull-up (~150k ohms) to v cc . i/o ports 3 and 4 are 5v tolerant, meaning they can be driven/pulled externally up to 5.5v without damage. the pins on port 4 have a higher current capability than the pins on ports 1 and 3. three additional mcu ports (only on 80-pin upsd34xx devices) are dedicated to bring out the 8032 mcu address, data, and control signals to external pins. one port, named mcuad[7:0], has eight multiplexed address/data bidirectional signals. the third port has mcu bus control outputs: read, write, program fetch, and address latch. these ports are typically used to connect external parallel peripherals and memory devices, but they may not be used as gpio. notice that the eight upper address signals do not come out to pins on the port. if high-order address signals ar e required on external pins (mcu addresses a[15:8]), then these address signals can be brought out as needed to pld output pins or to the address out mode pins on psd module ports. see psd module section, ? section 28.5.39: latched address output mode on page 232 for details. figure 16 on page 71 represents the flexibility of pin func tion routing controlled by the sfrs. each of the 24 pins on three ports, p1, p3, and p4, may be individually routed on a pin-by- pin basis to a desired function. 17.1 mcu port operating modes mcu port pins can operate as gpio or as alternate functions (see figure 17 on page 71 through figure 19 on page 72 ). depending on the selected pin function, a particular pin o perating mode will automatically be used: gpio - quasi-bidirectional mode uart0, uart1 - quasi-bidirectional mode spi - quasi-bidirectional mode i2c - open drain mode adc - analog input mode pca output - push-pull mode pca input - input only (quasi-bidirectional) timer 0,1,2 - input only (quasi-bidirectional)
i/o ports of mcu module upsd34xx 70/293 17.1.1 gpio function ports in gpio mode operate as quasi-bidire ctional pins, consistent with standard 8051 architecture. gpio pins are individually controlled by three sfrs: sfr, p1 ( table 27 on page 73 ) sfr, p3 ( table 28 on page 73 ) sfr, p4 ( table 29 on page 74 ) these sfrs can be accessed using the bit addressing mode, an efficient way to control individual port pins. 17.1.2 gpio output simply stated, when a logic '0' is written to a bit in any of these port sfrs while in gpio mode, the corresponding port pin will enable a low-side driver, which pulls the pin to ground, and at the same time releases the high-side driver and pull-ups, resulting in a logic '0' output. when a logic '1' is written to the sfr, the low-side driver is released, the high-side driver is enabled for just one mcu_clk period to rapidly make the 0-to1 transition on the pin, while weak active pull-ups (total ~150k ? ) to v cc are enabled. this structure is consistent with standard 8051 architecture. the high side driver is momentarily enabled only for 0-to-1 transitions, which is implemented with the delay function at the latch output as pictured in figure 17 on page 71 , figure 18 on page 72 , and figure 19 on page 72 . after the high-side driver is disabled, the two weak pull-ups remain enabled resulting in a logic '1' output at the pin, sourcing i oh ua to an external device. optionally, an external pull-up resistor can be added if additional source current is needed while outputting a logic '1.' 17.1.3 gpio input to use a gpio port pin as an input, the low-side driver to ground must be disabled, or else the true logic level being driven on the pin by an external device will be masked (always reads logic '0'). so to make a port pin ?input ready?, the corresponding bit in the sfr must have been set to a logic '1' prior to reading that sfr bit as an input. a reset condition forces sfrs p1, p3, and p4 to ffh, thus all three ports are input ready after reset. when a pin is used as an input, the stronger pull-up ?a? maintains a solid logic '1' until an external device drives the input pin low. at this time, pull-up ?a? is automatically disabled, and only pull-up ?b? will source the external device i ih ua, consistent with standard 8051 architecture. gpio bi-directional. it is possible to operate individual port pins in bi-directional mode. for an output, firmware would simply write the corresponding sfr bit to logic '1' or '0' as needed. but before using the pin as an input, firmware must first ensure that a logic '1' was the last value written to the corresponding sfr bit prior to reading that sfr bit as an input. gpio current capability. a gpio pin on port 4 can sink twice as much current than a pin on either port 1 or port 3 when the low-side driver is outputting a logic '0' (i ol ). see the dc specifications at the end of this document for full details. reading port pin vs. reading port latch. when firmware reads the gpio ports, sometimes the actual port pin is sampled in hardware, and sometimes the port sfr latch is read and not the actual pin, depending on the type of mcu instruction used. these two data paths are shown in figure 17 on page 71 through figure 19 on page 72 . sfr latches are read (and not the pins) only when the read is part of a read-modify-write instruction and the write destination is a bit or bits in a port sfr. these instructions are: anl, orl, xrl, jbc,
upsd34xx i/o ports of mcu module 71/293 cpl, inc, dec, djnz, mov, clr, and setb. all other types of reads to port sfrs will read the actual pin logic level and not the port latch. this is consistent with 8051 architecture. figure 16. mcu module port pin function routing figure 17. mcu i/o cell block diagram for port 1 8 p3 p1 p4 m c u a d gpio (8) uart0 (2) timer0/1 (4) i 2 c (2) gpio (8) gpio (8) timer2 (2) uart1 (2) spi (4) adc (8) pca (8) 8032 mcu core low addr & data[7:0] 8 hi address [15:8] (available on psd module pins) mcu module 8 on 80-pin devices only ports c n t l rd, wr, psen, ale 4 sfr 8 8 sfr sfr sfr sfr sfr ai09199b p1.x pin analog_alt_func_en analog_pin_in q d pre sfr p1.x latch 8032 data bus bit gpio p1.x sfr write latch mcu_reset p1.x sfr read latch (for r-m-w instructions) p1.x sfr read pin select_alternate_func digital_pin_data_in in 1 in 0 y mux v cc v cc v cc sel weak pull-up, b stonger pull-up, a low side high side delay, 1 mcu_clk delay, 1 mcu_clk q digital_alt_func_data_out ai09600
i/o ports of mcu module upsd34xx 72/293 figure 18. mcu i/o cell block diagram for port 3 figure 19. mcu i/o cell block diagram for port 4 p3.x pin digital_pin_data_in q d pre sfr p3.x latch 8032 data bus bit gpio p3.x sfr write latch mcu_reset p3.x sfr read latch (for r-m-w instructions) p3.x sfr read pin select_alternate_func disables high-side driver in 1 in 0 y mux v cc v cc v cc sel enable_i 2 c weak pull-up, b stonger pull-up, a low side high side delay, 1 mcu_clk delay, 1 mcu_clk q digital_alt_func_data_out ai09601 p4.x pin digital_pin_data_in q d pre sfr p4.x latch 8032 data bus bit gpio p4.x sfr write latch mcu_reset p4.x sfr read latch (for r-m-w instructions) p4.x sfr read pin select_alternate_func for pca alternate function in 1 in 0 y mux v cc v cc v cc sel enable_push_pull weak pull-up, b stonger pull-up, a low side high side delay, 1 mcu_clk delay, 1 mcu_clk q digital_alt_func_data_out ai09602
upsd34xx i/o ports of mcu module 73/293 table 27. p1: i/o port 1 register (sfr 90h, reset value ffh) note: 1 write '1' or '0' for pin output. read for pin input, but prior to read, this bit must have been set to '1' by firmware or by a reset event. table 28. p3: i/o port 3 register (sfr b0h, reset value ffh) note: 1 write '1' or '0' for pin output. read for pin input, but prior to read, this bit must have been set to '1' by firmware or by a reset event. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 bit symbol r/w function (1) 7 p1.7 r,w port pin 1.7 6 p1.6 r,w port pin 1.6 5 p1.5 r,w port pin 1.5 4 p1.4 r,w port pin 1.4 3 p1.3 r,w port pin 1.3 2 p1.2 r,w port pin 1.2 1 p1.1 r,w port pin 1.1 0 p1.0 r,w port pin 1.0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 bit symbol r/w function (1) 7 p3.7 r,w port pin 3.7 6 p3.6 r,w port pin 3.6 5 p3.5 r,w port pin 3.5 4 p3.4 r,w port pin 3.4 3 p3.3 r,w port pin 3.3 2 p3.2 r,w port pin 3.2 1 p3.1 r,w port pin 3.1 0 p3.0 r,w port pin 3.0
i/o ports of mcu module upsd34xx 74/293 table 29. p4: i/o port 4 register (sfr c0h, reset value ffh) note: 1 write '1' or '0' for pin output. read for pin input, but prior to read, this bit must have been set to '1' by firmware or by a reset event. 17.1.4 alternate functions there are five sfrs used to control the mapping of alternate functions onto mcu port pins, and these sfrs are depicted as switches in figure 16 on page 71 . port 3 uses the sfr, p3sfs ( table 30 on page 75 ). port 1 uses sfrs, p1sfs0 ( table 31 on page 75 ) and p1sfs1 ( table 32 on page 76 ). port 4 uses sfrs, p4sfs0 ( table 34 on page 76 ) and p4sfs1 ( table 35 on page 76 ). since these sfrs are cleared by a reset, then by default all port pins function as gpio (not the alternate function) until firmware initializes these sfrs. each pin on each of the three ports can be independently assigned a different function on a pin-by-pin basis. the peripheral functions timer 2, uart1, and i 2 c may be split independently between port 1 and port 4 for additional flexibility by giving a wider choice of peripheral usage on a limited number of device pins. when the selected alternate function is uart0, uart1, or spi, then the related pins are in quasi-bidirectional mode, including the use of the high-side driver for rapid 0-to-1 output transitions. the high-side driver is enabled for just one mcu_clk period on 0-to-1 transitions by the delay function at the ?digital_alt_func_data_out? signal pictured in figure 17 on page 71 through figure 19 on page 72 . if the alternate function is timer 0, timer 1, ti mer 2, or pca input, then the related pins are in quasi-bidirectional mode, but input only. if the alternate function is adc, then for each pin the pull-ups, the high-side driver, and the low-side driver are disabled. the analog input is routed directly to the adc unit. only port 1 supports analog functions ( figure 17 on page 71 ). port 1 is not 5v tolerant. if the alternate function is i 2 c, the related pins will be in open drain mode, which is just like quasi-bidirectional mode but the high-side driver is not enabled for one cycle when bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4.7 p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 p4.0 bit symbol r/w function (1) 7 p4.7 r,w port pin 4.7 6 p4.6 r,w port pin 4.6 5 p4.5 r,w port pin 4.5 4 p4.4 r,w port pin 4.4 3 p4.3 r,w port pin 4.3 2 p4.2 r,w port pin 4.2 1 p4.1 r,w port pin 4.1 0 p4.0 r,w port pin 4.0
upsd34xx i/o ports of mcu module 75/293 outputting a 0-to-1 transition. only the low-side driver and the internal weak pull-ups are used. only port 3 supports open-drain mode ( figure 18 on page 72 ). i 2 c requires the use of an external pull-up resistor on each bus signal, typically 4.7k ? to v cc . if the alternate function is pca output, then the related pins are in push-pull mode, meaning the pins are actively driven and held to logic '1' by the high-side driver, or actively driven and held to logic '0' by the low-side driver. only port 4 supports push-pull mode ( figure 19 on page 72 ). port 4 push-pull pins can source i oh current when driving logic '1,' and sink i ol current when driving logic '0.' this current is significantly more than th e capability of pins on port 1 or port 3 (see table 156 on page 265 ). for example, to assign these port functions: port 1: uart1, adc[1:0], p1[7:4] are gpio port 3: uart0, i 2 c, p3[5:2] are gpio port 4: tcm0, spi, p4[3:1] are gpio the following values need to be written to the sfrs: p1sfs0 = 00001111b, or 0fh p1sfs1 = 00000011b , or 03h p3sfs = 11000011b, or c3h p4sfs0 = 11110001b, or f1h p4sfs1 = 11110000b, or f0h table 30. p3sfs: port 3 special function select register (sfr 91h, reset value 00h) table 31. p1sfs0: port 1 special function select 0 register (sfr 8eh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p3sfs7 p3sfs6 p3sfs5 p3sfs4 p3sfs3 p3sfs2 p3sfs1 p3sfs0 port 3 pin r/w default port function al ternate port function p3sfs[i] - 0; port 3 pin, i = 0..7 p3sfs[i] - 1; port 3 pin, i = 0..7 0 r,w gpio uart0 receive, rxd0 1 r,w gpio uart0 transmit, txd0 2 r,w gpio ext intr 0/timer 0 gate, ext0int/tg0 3 r,w gpio ext intr 1/timer 1 gate, ext1int/tg1 4 r,w gpio counter 0 input, c0 5 r,w gpio counter 0 input, c1 6 r,w gpio i 2 c data, i2csda 7 r,w gpio i 2 c clock, i2ccl bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1sf07 p1sf06 p1sf05 p1sf04 p1sf03 p1sf02 p1sf01 p1sf00
i/o ports of mcu module upsd34xx 76/293 table 32. p1sfs1: port 1 special function select 1 register (sfr 8fh, reset value 00h) table 33. p1sfs0 and p1sfs1 details table 34. p4sfs0: port 4 special function select 0 register (sfr 92h, reset value 00h) table 35. p4sfs1: port 4 special function select 1 register (sfr 93h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1sf17 p1sf16 p1sf15 p1sf14 p1sf13 p1sf12 p1sf11 p1sf10 port 1 pin r/w default port function alternate 1 port function alternate 2 port function p1sfs0[i] = 0 p1sfs1[i] = x p1sfs0[i] = 1 p1sfs1[i] = 0 p1sfs0[i] = 1 p1sfs1[i] = 1 port 1 pin, i = 0.. 7 port 1 pin, i = 0.. 7 port 1 pin, i = 0.. 7 0 r,w gpio timer 2 count input, t2 adc chn 0 input, adc0 1 r,w gpio timer 2 trigger input, tx2 adc chn 1 input, adc1 2 r,w gpio uart1 receive, rxd1 adc chn 2 input, adc2 3 r,w gpio uart1 transmit, txd1 adc chn 3 input, adc3 4 r,w gpio spi clock, spiclk adc chn 4 input, adc4 5 r,w gpio spi receive, spirxd adc chn 5 input, adc5 6 r,w gpio spi transmit, spitxd adc chn 6 input, adc6 7 r,w gpio spi select, spisel_ adc chn 7 input, adc7 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4sf07 p4sf06 p4sf05 p4sf04 p4sf03 p4sf02 p4sf01 p4sf00 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4sf17 p4sf16 p4sf15 p4sf14 p4sf13 p4sf12 p4sf11 p4sf10
upsd34xx i/o ports of mcu module 77/293 table 36. p4sfs0 and p4sfs1 details port 4 pin r/w default port function alternate 1 port function alternate 2 port function p4sfs0[i] = 0 p4sfs1[i] = x p4sfs0[i] = 1 p4sfs1[i] = 0 p4sfs0[i] = 1 p4sfs1[i] = 1 port 4 pin, i = 0.. 7 port 4 pin, i = 0.. 7 port 4 pin, i = 0.. 7 0 r,w gpio pca0 module 0, tcm0 timer 2 count input, t2 1 r,w gpio pca0 module 1, tcm1 timer 2 trigger input, tx2 2 r,w gpio pca0 module 2, tcm2 uart1 receive, rxd1 3 r,w gpio pca0 ext clock, pcaclk0 uart1 transmit, txd1 4 r,w gpio pca1 module 3, tcm3 spi clock, spiclk 5 r,w gpio pca1 module 4, tcm4 spi receive, spirxd 6 r,w gpio pca1 module 5, tcm5 spi transmit, spitxd 7 r,w gpio pca1 ext clock, pcaclk1 spi select, spisel_
mcu bus interface upsd34xx 78/293 18 mcu bus interface the mcu module has a programmable bus interface which is a modified 8032 bus with 16 multiplexed address and data lines. the bus supports four types of data transfer (16- or 8- bit), each transfer is to/from a memory location external to the mcu module: code fetch cycle using the psen signal: fe tch a 16-bit code word for filling the pre- fetch queue. the cpu fetches a code byte from the pfq for execution; code read cycle using psen: read a 16-bit code word using the movc (move constant) instruction. the code word is routed directly to the cpu and by-pass the pfq; xdata read cycle using the rd signal: read a data byte using the movx (move external) instruction; and xdata write cycle using the wr signal: write a data byte using the movx instruction 18.1 psen bus cycles in a psen bus cycle, the mcu module fetches the instruct ion from the 16-bit program memory in the psd module. the multiplexed address/data bus ad[15:0] is connected to the psd module for 16-bit data tran sfer. the upsd34xx does not support external psen cycles and cannot fetch instruction from other external program memory devices. 18.2 read or write bus cycles in an xdata read or write bus cycle, the mcu?s multiplexed ad[15:0] bus is connected to the psd module, but only the lower bytes ad[7:0] are used for the 8-bit data transfer. the ad[7:0] lines are also connected to pins in the 80-pin package for accessing external devices. if the high address byte a[15:8] is needed for external devices, port b in the psd module can be configured to provide the latched a[15:8] address outputs. 18.3 connecting external devices to the mcu bus the upsd34xx supports 8-bit only external i/ o or data memory devices. the read and write data transfer is carried out on the ad[7:0] bus which is available in the 80-pin package. the address lines can be brought out to the external devices in one of three ways: 1. configure ports b and a of the psd module in address output mode, as shown in figure 20 ; 2. use port b together with an external latch, as shown in figure 21 on page 79 . the external latch latches the low address byte from the ad[7:0] bus with the ale signal.this configuration is for design wher e port a is needed for cpld functions; and 3. configure the microcell in the cpld to output any address line to any of the cpld output pins. this is the most flexible implementation but requires the use of cpld resources. ports a and b in the psd module can be configured in the psdsoft to provide latched mcu address a[7:0] and a[15:8] (see section 28.5: psd module detailed operation on page 201 for details on how to enable address output mode). the latched address outputs on the ports are pin configurable. for example, port b pins pb[2:0] can be enabled to provide
upsd34xx mcu bus interface 79/293 a[10:8] and the remaining pins can be configured for other functions such as generating chip selects to the external devices. figure 20. connecting external devices using ports a and b for address ad[15:0] figure 21. connecting external devices using port a and an external latch for address ad[15:0] 18.4 programmable bus timing the length of the bus cycles are user programmable at run time. the number of mcu_clk periods in a bus cycle can be specified in the sfr register named buscon (see ta b l e 3 7 on page 81 ). by default, the buscon register is loaded with long bus cycle times (6 mcu_clk periods) after a reset co ndition. it is important that the post-reset initialization firmware sets the bus cycle times appropriately to get the most performance, according to table 38 on page 82 . keep in mind that the psd module has a faster turbo mode (default) and a slower but less power consuming non-turbo mode. the bus cycle times must be programmed in buscon to optimize for each mode as shown in ta b l e 3 8 . see section 28.5: psd module detailed operation on page 201 for more details. upsd34xx psd module external 8-bit device mcu module ai10434 ad[7:0] d[7:0] a8-15 a0-7 port a cs port b ad[15:8] psen ale rd or wr rd or wr upsd34xx psd module external 8-bit device l a t c h mcu module ai10435 ad[7:0] d[7:0] a7-0 a8-15 cs port b ad[15:8] psen ale rd or wr rd or wr
mcu bus interface upsd34xx 80/293 it is not possible to specify in the buscon register a different number of mcu_clk periods for various address ranges. for example, the user cannot specify 4 mcu_clk periods for rd read cycles to one address range on the psd module, and 5 mcu_clk periods for rd read cycles to a different address range on an external device. however, the user can specify one nu mber of clock periods for psen read cycles and a different number of clock periods for rd or wr cycles (see figure 22 on page 80 ). 18.5 controlling the pfq and bc the buscon register allows firmware to enable and disable the pfq and bc at run-time. sometimes it may be desired to disable the pfq and bc to ensure deterministic execution. the dynamic action of the pfq and bc ma y cause varying program execution times depending on the events that happen prior to a particular section of code of interest. for this reason, it is not recommended to implement timing loops in firmware, but instead use one of the many hardware timers in the upsd34xx. by default, the pfq and bc are enabled after a reset condition. important note: disabling the pfq or bc will seriously reduce mcu performance. figure 22. a rd or psen bus cycle set to 5 mcu_clk note: 1 the psen cycle is 16-bit, whil e the rd cycle is 8-bit only. 2 a psen bus cycle in progress may be aborted before completion if the pfq and branch cache (bc) determines the current code fetch cycle is not needed. 3 whenever the same number of mcu_clk perio ds is specified in buscon for both psen and rd cycles, the bus cycle timing is typically identical for each of these types of bus cycles. in this case, the only ti me psen read cycles ar e longer than rd read cycles is when the pfq issues a stall while reloading. pfq stalls do not affect rd read cycles. by comparison, in many traditional 8051 architectures, rd bus cycles are always longer than psen bus cycles. a0-a15 mcu clock ale ad0-ad15 1 2 3 4 5 d0-d15 (1) 5-clock bus cycle rd/psen (2,3) ai10436
upsd34xx mcu bus interface 81/293 table 37. buscon: bus control register (sfr 9dh, reset value ebh) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 epfq ebc wrw[1:0] rdw[1:0] cw[1:0] bit symbol r/w definition 7 epfq r,w enable pre-fetch queue 0 = pfq is disabled 1 = pfq is enabled (default) 6 ebc r,w enable branch cache 0 = bc is disabled 1 = bc is enabled (default) 5:4 wrw[1:0] r,w wr wait, number of mcu_clk periods for wr write bus cycle during any movx instruction 00b: 4 clock periods 01b: 5 clock periods 10b: 6 clock periods (default) 11b: 7 clock periods 3:2 rdw[1:0] r,w rd wait, number of mcu_clk periods for rd read bus cycle during any movx instruction 00b: 4 clock periods 01b: 5 clock periods 10b: 6 clock periods (default) 11b: 7 clock periods 1:0 cw[1:0] r,w code wait, number of mcu_clk periods for psen read bus cycle during any code byte fetch or during any movc code byte read instruction. periods will increase with pfq stall 00b: 3 clock periods - exception, for movc instructions this setting results 4 clock periods 01b: 4 clock periods 10b: 5 clock periods 11b: 6 clock periods (default)
mcu bus interface upsd34xx 82/293 table 38. number of mcu_clk periods requ ired to optimize bus transfer rate note: 1 v dd of the psd module 2 ?turbo mode psd? means that the psd module is in the faster, turbo mode (default condition). a psd module in non-turbo mode is slower, but consumes less current. see psd module section, titled ?pld non-turbo mode? for details. mcu clock frequency, mcu_clk (f mcu ) cw[1:0] clk periods rdw[1:0] clk periods wrw[1:0] clk periods 3.3v (1) 5v (1) 3.3v (1) 5v (1) 3.3v (1) 5v (1) 40mhz, turbo mode psd (2) 545454 40mhz, non-turbo mode psd 6 5 6 5 6 5 36mhz, turbo mode psd 545454 36mhz, non-turbo mode psd 6 4 6 4 6 4 32mhz, turbo mode psd 545454 32mhz, non-turbo mode psd 5 4 5 4 5 4 28mhz, turbo mode psd 434444 28mhz, non-turbo mode psd 5 4 5 4 5 4 24mhz, turbo mode psd 434444 24mhz, non-turbo mode psd 4 3 4 4 4 4 20mhz and below, turbo mode psd 3 3 4 4 4 4 20mhz and below, non-turbo mode psd 334444
upsd34xx supervisory functions 83/293 19 supervisory functions supervisory circuitry on the mcu module will i ssue an internal rese t signal to the mcu module and simultaneously to the psd module as a result of any of the following four events: the external reset_in pin is asserted the low voltage detect (lvd) circuitry has detected a voltage on v cc below a specific threshold (power-on or voltage sags) the jtag debug interface has issued a reset command the watch dog timer (wdt) has timed out the resulting internal reset signal, mcu_rese t, will force the 8032 into a known reset state while asserted, and then 8032 program execution will jump to the reset vector at program address 0000h just after mcu_ reset is deasserted. the mcu module will also assert an active low internal reset signal, reset , to the psd module. if needed, the signal reset can be driven out to external system compo nents through any pld ou tput pin on the psd module. when driving this ?reset_out? signal from a pld output, the user can choose to make it either active-high or active-low logic, depending on the pld equation. 19.1 external reset input pin, reset_in the reset_in pin can be connected directly to a mechanical reset switch or other device which pulls the signal to ground to invoke a reset. reset_in is pulled up internally and enters a schmitt trigger input buffer with a voltage hysteresis of v rst_hys for immunity to the effects of slow signal rise and fall times, as shown in figure 23 . reset_in is also filtered to reject a voltage spike less than a duration of t rst_fil . the reset_in signal must be maintained at a logic '0' for at least a duration of t rst_lo_in while the oscillator is runn ing. the resulting mcu_reset signal will last only as long as the reset_in signal is active (it is not stretched). refer to the supervisor ac specifications in table 178 on page 279 at the end of this document for these parameter values. figure 23. supervisor reset generation q s mcu clock sync noise filter v cc pin pull-up delay, t rst_actv r ai09603 reset_in reset to psd module mcu_reset to mcu and peripherals lv d jtag debug wdt
supervisory functions upsd34xx 84/293 19.2 low v cc voltage detect, lvd an internal reset is generated by the lvd circuit when v cc drops below the reset threshold, v lv_thresh . after v cc returns to the reset threshold, the mcu_reset signal will remain asserted for t rst_actv before it is released. the lvd circuit is always enabled (cannot be disabled by sfr), even in idle mode and power-down mode. the lvd input has a voltage hysteresis of v rst_hys and will reject voltage spikes less than a duration of t rst_fil . important note: the lvd voltage threshold is v lv_thresh , suitable for monitoring both the 3.3v v cc supply on the mcu module and the 3.3v v dd supply on the psd module for 3.3v upsd34xxv devices, since these supplies ar e one in the same on the circuit board. however, for 5v upsd34xx devices, v lv_thresh is not suitable for monitoring the 5v v dd voltage supply (v lv _ t h r es h is too low), but good for monitoring the 3.3v v cc supply. in the case of 5v upsd34xx devices, an external means is required to monitor the separate 5v v dd supply, if desired. 19.3 power-up reset at power up, the internal reset generated by t he lvd circuit is latched as a logic '1' in the por bit of the sfr named pcon ( table 26 on page 66 ). software can read this bit to determine whether the last mcu reset was the result of a power up (cold reset) or a reset from some other condition (warm reset). this bit must be cleared with software. 19.4 jtag debug reset the jtag debug unit can generate a reset for debugging purposes. this reset source is also available when the mcu is in idle mode and power-down mode (the user can use the jtag debugger to exit these modes). 19.5 watchdog timer, wdt when enabled, the wdt will gener ate a reset whenever it overflows. firmware that is behaving correctly will periodic ally clear the wdt before it overflows. run-away firmware will not be able to clear the wd t, and a reset will be generated. by default, the wdt is disabled after each reset. note: the wdt is not active during idle mode or power-down mode. there are two sfrs that control the wdt, they are wdkey ( table 39 on page 86 ) and wdrst ( table 40 on page 86 ). if wdkey contains 55h, the wdt is disabl ed. any value other th an 55h in wdkey will enable the wdt. by default, after any reset condition, wdkey is automatically loaded with 55h, disabling the wdt. it is the responsibility of initialization firmware to write some value other than 55h to wdkey after each reset if the wdt is to be used. the wdt consists of a 24-bit up-counter ( figure 24 ), whose initial count is 000000h by default after every reset. the most significant byte of this counter is controlled by the sfr, wdrst. after being enabled by wdkey, the 24-bit count is increased by 1 for each mcu machine cycle. when the count overflows beyond fffffh (2 24 mcu machine cycles), a reset is issued and the wdt is automa tically disabled (wdkey = 55h again).
upsd34xx supervisory functions 85/293 to prevent the wdt from timing out and generating a reset, firmware must repeatedly write some value to wdrst before the count reache s fffffh. whenever wdrst is written, the upper 8 bits of the 24-bit counter are loaded with the written value, and the lower 16 bits of the counter are cleared to 0000h. the wdt time-out period can be adjusted by writing a value other that 00h to wdrst. for example, if wdrst is written with 04h, th en the wdt will start coun ting 040000h, 040001h, 040002h, and so on for each mcu machine cycle. in this example, the wdt time-out period is shorter than if wdrst was written with 00h, because the wdt is an up-counter. a value for wdrst should never be written that results in a wdt time-out period shorter than the time required to complete the longest code task in the application, else unwanted wdt overflows will occur. figure 24. watchdog counter the formula to determine wdt time-out period is: wdt period = t mach_cyc x n overflow n overflow is the number of wdt up-counts required to reach ffffffh. this is determined by the value written to the sfr, wdrst. t mach_cyc is the average duration of one mcu ma chine cycle. by default, an mcu machine cycle is always 4 mcu_clk periods for upsd34xx, but the following factors can sometimes add more mcu_clk periods per machine cycle: the number of mcu_clk periods assigned to mcu memory bus cycles as determined in the sfr, buscon. if this setting is greater than 4, then machine cycles have additional mcu_clk periods during memory transfers. whether or not the pfq/bc circuitry issues a stall during a particular mcu machine cycle. a stall adds more mcu_clk periods to a machine cycle until the stall is removed. t mach_cyc is also affected by the absolute time of a single mcu_clk period. this number is fixed by the following factors: frequency of the external crystal , resonator, or oscillator: (f osc ) bit settings in the sfr ccon0, which can divide f osc and change mcu_clk as an example, assume the following: 1. f osc is 40mhz, thus its period is 25ns. 2. ccon0 is 10h, meaning no clock division, so the period of mcu_clk is also 25ns. 3. buscon is c1h, meaning the pfq and bc are enabled, and each mcu memory bus cycle is 4 mcu_clk periods, adding no additional mcu_clk periods to mcu machine cycles during memory transfers. 4. assume there are no stalls from the pfq/bc. in reality, there are occational stalls but their occurance has minimal impact on wdt timeout period. 5. wdrst contains 00h, meaning a full 2 24 up-counts are required to reach fffffh and generate a reset. 23 15 7 0 8-bits 8-bits 8-bits sfr, wdrst ai09604
supervisory functions upsd34xx 86/293 in this example, t mach_cyc = 100ns (4 mcu_clk periods x 25ns) n overflow = 2 24 = 16777216 up-counts wdt period = 100ns x 16777216 = 1.67 seconds the actual value will be slight ly longer due to pfq/bc. 19.5.1 firmwar e example: the following 8051 assembly c ode illustrates how to operate the wdt. a simple statement in the reset initialization firmwa re enables the wdt, and then a periodic write to clear the wdt in the main firmware is required to keep the wdt from overflowing. this firmware is based on the example above (40mhz f osc , ccon0 = 10h, buscon = c1h). for example, in the reset initialization firmware (the function that executes after a jump to the reset vector): somewhere in the flow of the ma in program, this statement will execute periodically to reset the wdt before its time-out period of 1.67 seconds. for example: table 39. wdkey: watchdog timer key register (sfr aeh, reset value 55h) table 40. wdrst: watchdog timer reset counter register (sfr a6h, reset value 00h) mov ae, #aa ; enable wdt by writing value to ; wdkey other than 55h mov a6, #00 ; reset wdt, loading 000000h. ; counting will automatically ; resume as long as 55h in not in ; wdkey bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 wdkey[7:0] bit symbol r/w definition [7:0] wdkey w 55h disables the wdt from c ounting. 55h is automatically loaded in this sfr after any reset condition, leaving the wdt disabled by default. any value other than 55h written to this sfr will enable the wdt, and counting begins. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 wdrst[7:0] bit symbol r/w definition [7:0] wdrst w this sfr is the upper byte of the 24-bit wdt up-counter. writing this sfr sets the upper byte of the counter to the written value, and clears the lower two bytes of the counter to 0000h. counting begins when wdkey does not contain 55h.
upsd34xx standard 8032 timer/counters 87/293 20 standard 8032 timer/counters there are three 8032-style 16-bit timer/counter registers (timer 0, timer 1, timer 2) that can be configured to operate as timers or event counters. there are two additional 16-bit timer/counters in the programmable counter array (pca), see section 27.1: pca block on page 175 for details. 20.1 standard timer sfrs timer 0 and timer 1 have very similar functions, and they share two sfrs for control: tcon ( table 41 on page 88 ) tmod ( table 42 on page 90 ). timer 0 has two sfrs that form the 16-bit counter, or that can hold reload values, or that can scale the clock depending on the timer/counter mode: th0 is the high byte, address 8ch tl0 is the low byte, address 8ah timer 1 has two similar sfrs: th1 is the high byte, address 8dh tl1 is the low byte, address 8bh timer 2 has one control sfr: t2con ( table 43 on page 93 ) timer 2 has two sfrs that form the 16-bit counter, and perform other functions: th2 is the high byte, address cdh tl2 is the low byte, address cch timer 2 has two sfrs for capture and reload: rcap2h is the high byte, address cbh rcap2l is the low byte, address cah 20.2 clock sources when enabled in the ? timer ? function, the registers thx and tlx are incremented every 1/12 of the osc illator frequency (f osc ). this timer clock source is not effected by mcu clock dividers in the ccon0, stalls from pfq/bc, or bus transfer cycles. timers are always clocked at 1/12 of f osc . when enabled in the ? counter ? function, the registers thx and tlx are incremented in response to a 1-to-0 transition sampled at their corresponding external input pin: pin c0 for timer 0; pin c1 for timer 1; or pin t2 for timer 2. in this function, the external clock input pin is sampled by the counter at a rate of 1/12 of f osc . when a logic '1' is determined in one sample, and a logic '0' in the next sample period, the count is incremented at the very next sample period (period1: sample=1, period2: sample=0, period3: increment count while continuing to sample). this means the maximum count rate is 1/24 of the f osc . there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be active for at least one full sample
standard 8032 timer/counters upsd34xx 88/293 period (12 / f osc, seconds). however, if mcu_clk is divided by the sfr ccon0, then the sample period must be calculated based on the resultant, longer, mcu_clk frequency. in this case, an external clock signal on pins c0, c1, or t2 should have a duration longer than one mcu machine cycle, t mach_cyc . section 19.5: watchdog timer, wdt on page 84 explains how to estimate t mach_cyc . table 41. tcon: timer control register (sfr 88h, reset value 00h) 20.3 sfr, tcon timer 0 and timer 1 share the sfr, tcon, that controls these timers and provides information about them. see table 41 on page 88 . bits ie0 and ie1 are not related to timer/counter functions, but they are set by hardware when a signal is active on one of the two external interrupt pins, extint0 and extint1. for system information on all of these interrupts, see table 16 on page 53 , interrupt summary. bits it0 and it1 are not related to timer/counter functions, but they control whether or not the two external interrupt input pins, extint0 and extint1 are edge or level triggered. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 bit symbol r/w definition 7tf1r timer 1 overflow interrupt flag. set by hardware upon overflow. automatically cleared by hardware after firmware services the interrupt for timer 1. 6 tr1 r,w timer 1 run control. 1 = timer/counter 1 is on, 0 = timer/counter 1 is off. 5tf0r timer 0 overflow interrupt flag. set by hardware upon overflow. automatically cleared by hardware after firmware services the interrupt for timer 0. 4 tr0 r,w timer 0 run control. 1 = timer/counter 0 is on, 0 = timer/counter 0 is off. 3ie1r interrupt flag for external in terrupt pin, extint1. set by hardware when edge is detected on pin. automatically cleared by hardware after firmware services extint1 interrupt. 2it1r,w trigger type for external interrupt pin extint1. 1 = falling edge, 0 = low-level 1ie0r interrupt flag for external in terrupt pin, extint0. set by hardware when edge is detected on pin. automatically cleared by hardware after firmware services extint0 interrupt. 0it0r,w trigger type for external interrupt pin extint0. 1 = falling edge, 0 = low-level
upsd34xx standard 8032 timer/counters 89/293 20.4 sfr, tmod timer 0 and timer 1 have four modes of operation controlled by the sfr named tmod ( ta bl e 4 2 ). 20.5 timer 0 and time r 1 operating modes the ?timer? or ?counter? function is selected by the c/t control bits in tmod. the four operating modes are selected by bit-pairs m[1:0] in tmod. modes 0, 1, and 2 are the same for both timer/counters. mode 3 is different. 20.5.1 mode 0 putting either timer/counter into mode 0 makes it an 8-bit counter with a divide-by-32 pre- scaler. figure 25 shows mode 0 operation as it applies to timer 1 (same applies to timer 0). in this mode, the timer register is configured as a 13-bit register. as the count rolls over from all '1s' to all '0s,' it sets the timer interrupt flag tf1. the counted input is enabled to the timer when tr1 = 1 and either gate = 0 or extint1 = 1. (setting gate = 1 allows the timer to be controlled by external input pin, extint1, to facilitate pulse width measurements). tr1 is a control bit in the sfr, tcon. gate is a bit in the sfr, tmod. the 13-bit register consists of all 8 bits of th 1 and the lower 5 bits of tl1. the upper 3 bits of tl1 are indeterminate and should be ignored. setting the run flag, tr1, does not clear the registers. mode 0 operation is the same for the timer 0 as for timer 1. substitute tr0, tf0, c0, tl0, th0, and extint0 for the corresponding timer 1 signals in figure 25 . there are two different gate bits, one for timer 1 and one for timer 0. 20.5.2 mode 1 mode 1 is the same as mode 0, except that the timer register is being run with all 16 bits. 20.5.3 mode 2 mode 2 configures the timer register as an 8-bit counter (tl1) with automatic reload, as shown in figure 26 on page 91 . overflow from tl1 not only sets tf1, but also reloads tl1 with the contents of th1, which is preset with firmware. the reload leaves th1 unchanged. mode 2 operation is the same for timer/counter 0. 20.5.4 mode 3 timer 1 in mode 3 simply holds its count. the effect is the same as setting tr1 = 0. timer 0 in mode 3 establishes tl0 and th0 as two separate counters. the logic for mode 3 on timer 0 is shown in figure 27 on page 91 . tl0 uses the timer 0 control bits: c/t , gate, tr0, and tf0, as well as the pin extint0. th0 is locked into a timer function (counting at a rate of 1/12 f osc ) and takes over the use of tr1 and tf1 from timer 1. thus, th0 now controls the ?timer 1? interrupt flag. mode 3 is provided for applications requiring an extra 8-bit timer on the counter (see figure 27 on page 91 ). with timer 0 in mode 3, a upsd34xx device can look like it has three timer/counters (not including the pca). when timer 0 is in mode 3, timer 1 can be
standard 8032 timer/counters upsd34xx 90/293 turned on and off by switching it out of and into its own mode 3, or can still be used by the serial port as a baud rate generator, or in fact, in any application not requiring an interrupt. table 42. tmod: timer mode register (sfr 89h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 gate c/t m[1:0] gate c/t m[1:0] bit symbol r/w timer definition (t/c is abbreviation for timer/counter) 7gater,w timer 1 gate control. when gate = 1, t/c is enabled only while pin extint1 is '1' and the flag tr1 is '1.' when gate = 0, t/c is enabled whenever the flag tr1 is '1.' 6c/t r,w counter or timer function select. when c/t = 0, function is timer, clocked by internal clock. c/t = 1, function is counter, clocked by signal sampled on external pin, c1. [5:4] m[1:0] r,w mode select. 00b = 13-bit t/c. 8 bits in th1 with tl1 as 5-bit pre- scaler. 01b = 16-bit t/c. th1 and tl1 are cascaded. no pre- scaler. 10b = 8-bit auto-reload t/c. th1 holds a constant and loads into tl1 upon overflow. 11b = timer counter 1 is stopped. 3gater,w timer 0 gate control. when gate = 1, t/c is enabled only while pin extint0 is '1' and the flag tr0 is '1.' when gate = 0, t/c is enabled whenever the flag tr0 is '1.' 2c/t r,w counter or timer function select. when c/t = 0, function is timer, clocked by internal clock. c/t = 1, function is counter, clocked by signal sampled on external pin, c0. [1:0] m[1:0] r,w mode select. 00b = 13-bit t/c. 8 bits in th0 with tl0 as 5-bit pre- scaler. 01b = 16-bit t/c. th0 and tl0 are cascaded. no pre- scaler. 10b = 8-bit auto-reload t/c. th0 holds a constant and loads into tl0 upon overflow. 11b = tl0 is 8-bit t/c controlled by standard timer 0 control bits. th0 is a separate 8-bit timer that uses timer 1 control bits.
upsd34xx standard 8032 timer/counters 91/293 figure 25. timer/counter mode 0: 13-bit counter figure 26. timer/counter mode 2: 8-bit auto-reload figure 27. timer/counter mode 3: two 8-bit counters 20.6 timer 2 timer 2 can operate as either an event timer or as an event counter. this is selected by the bit c/t2 in the sfr named, t2con ( table 43 on page 93 ). timer 2 has three operating modes selected by bits in t2con, a ccording to table 44 on page 94 . the three modes are: capture mode auto re-load mode baud rate generator mode ai06622 f osc tf1 interrupt gate tr1 extint1 pin c1 pin control tl1 (5 bits) th1 (8 bits) c/t = 0 c/t = 1 12 ai06623 f osc tf1 interrupt gate tr1 extint1 pin c1 pin control tl1 (8 bits) th1 (8 bits) c/t = 0 c/t = 1 12 ai06624 f osc tf0 interrupt gate tr0 extint0 pin c0 pin control tl0 (8 bits) c/t = 0 c/t = 1 12 f osc tf1 interrupt control th0 (8 bits) 12 tr1
standard 8032 timer/counters upsd34xx 92/293 20.6.1 capture mode in capture mode there are tw o options which are selected by the bit exen2 in t2con. figure 28 on page 97 illustrates capture mode. if exen2 = 0, then timer 2 is a 16-bit timer if c/t2 = 0, or it is a 16 -bit counter if c/t2 = 1, either of which sets the interrupt flag bit tf2 upon overflow. if exen2 = 1, then timer 2 still does the above, but with the added f eature that a 1-to-0 transition at external input pin t2x causes th e current value in the timer 2 registers, tl2 and th2, to be captured into registers rcap2l and rcap2h, respectively. in addition, the transition at t2x causes interrupt flag bit exf2 in t2con to be set. either flag tf2 or exf2 will generate an interrupt and the mcu must read both flags to determine the cause. flags tf2 and exf2 are not automatically cleared by hardware, so the firmware servicing the interrupt must clear the flag(s) upon exit of the interrupt service routine. 20.6.2 auto-reload mode in the auto-reload mode, there are again two options, which are selected by the bit exen2 in t2con. figure 29 on page 97 shows auto-reload mode. if exen2 = 0, then when timer 2 co unts up and rolls over from ffffh it not only sets the interrupt flag tf2, but also causes the timer 2 registers to be reloaded with the 16-bit value contained in registers rcap2l and rcap2h, which are preset with firmware. if exen2 = 1, then timer 2 still does the above, but with the added f eature that a 1-to-0 transition at external input t2x will also trigge r the 16-bit reload and set the interrupt flag exf2. again, firmware servicing the interrupt must read both tf2 and exf2 to determine the cause, and clear the flag(s) upon exit. note: the upsd34xx does not support selectable up/down counting in auto-reload mode (this feature was an extension to the original 8032 architecture).
upsd34xx standard 8032 timer/counters 93/293 table 43. t2con: timer 2 control register (sfr c8h, reset value 00h) note: 1 the rclk1 and tclk1 bits in the sfr named pcon control uart1, and have the exact same function as rclk and tclk. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl 2 bit symbol r/w definition 7tf2r,w timer 2 flag, causes interrupt if enabled. tf2 is set by hardware upon overflow. must be cleared by firmware. tf2 will not be set when either rclk or tclk =1. 6 exf2 r,w timer 2 flag, causes interrupt if enabled. exf2 is set when a capture or reload is caused by a negative transition on t2x pin and exen2 = 1. exf2 must be cleared by firmware. 5 rclk (1) r,w uart0 receive clock control. when rclk = 1, uart0 uses timer 2 overflow pulses for its receive clock in modes 1 and 3. rclk=0, timer 1 overflow is used for its receive clock 4tclk (1) r,w uart0 transmit clock control. when tclk = 1, uart0 uses timer 2 overflow pulses for its transmit clock in modes 1 and 3. tclk=0, timer 1 overflow is used for transmit clock 3 exen2 r,w timer 2 external enable. when exen2 = 1, capture or reload results when negative edge on pin t2x occurs. exen2 = 0 causes timer 2 to ignore events at pin t2x. 2 tr2 r,w timer 2 run control. 1 = timer/counter 2 is on, 0 = timer counter 2 is off. 1c/t2 r,w counter or timer function select. when c/t2 = 0, function is timer, clocked by internal clock. when c/t2 = 1, function is counter, clocked by signal sampled on external pin, t2. 0cp/rl2 r,w capture/reload. when cp/rl2 = 1, capture occurs on negative transition at pin t2x if exen2 = 1. when cp/rl2 = 0, auto-reload occurs when timer 2 overflows, or on negative transition at pin t2x when exen2=1. when rclk = 1 or tclk = 1, cp/rl2 is ignored, and timer 2 is forced to auto-reload upon timer 2 overflow
standard 8032 timer/counters upsd34xx 94/293 table 44. timer/counter 2 operating modes note: = falling edge 20.6.3 baud rate generator mode the rclk and/or tclk bits in the sfr t2co n allow the transmit an d receive baud rates on serial port uart0 to be derived from either timer 1 or timer 2. figure 30 on page 98 illustrates baud rate generator mode. when tclk = 0, timer 1 is used as uart0?s transmit baud generator. when tclk = 1, timer 2 will be the transmit baud generator. rc lk has the same effect for uart0?s receive baud rate. with these two bits, uart0 can ha ve different receive and transmit baud rates - one generated by timer 1, the other by timer 2. note: bits rclk1 and tclk1 in the sfr named pcon (see section table 26.: pcon: power control register (sfr 87h, reset value 00h) on page 66 ) have identical functions as rclk and tclk but they apply to uart1 instead. for simplicity in the following discussions about baud rate generation, no suffix will be used when referring to sfr regi sters and bits related to uart0 or uart1, since each uart interface has identical operation. example, tclk or tclk1 will be referred to as just tclk. the baud rate generator mode is similar to the auto-reload mode, in that a roll over in th2 causes the timer 2 registers, th2 and tl2, to be reloaded with the 16-bit value in registers rcap2h and rcap2l, which are preset with firmware. the baud rates in uart modes 1 and 3 are determined by timer 2?s overflow rate as follows: uart mode 1,3 baud rate =timer 2 overflow rate / 16 mode bits in t2con sfr pin t2x remarks input clock rclk or tclk cp/ rl2 tr2 exen2 timer, internal counter, external (pin t2, p1.0) 16-bit auto- reload 001 0 x reload [rcap2h, rcap2l] to [th2, tl2] upon overflow (up counting) f osc /12 max f osc /24 001 1 reload [rcap2h, rcap2l] to [th2, tl2] at falling edge on pin t2x 16-bit capture 011 0 x 16-bit timer/counter (up counting) f osc /12 max f osc /24 011 1 capture [th2, tl2] and store to [rcap2h, rcap2l] at falling edge on pin t2x baud rate generato r 1x1 0 x no overflow interrupt request (tf2) f osc /2 ? 1x1 1 extra interrupt on pin t2x, sets tf2 off x x 0 x x timer 2 stops ? ?
upsd34xx standard 8032 timer/counters 95/293 the timer can be configured for either ?timer? or ?counter? operation. in the most typical applications, it is configured for ?timer? operation (c/t2 = 0). ?timer? operation is a little different for timer 2 when it's being used as a baud rate generator. in this case, the baud rate is given by the formula: uart mode 1,3 baud rate =f osc /(32 x [65536 ? [rcap2h, rcap2l])) where [rcap2h, rcap2l] is the content of the sfrs rcap2h and rcap2l taken as a 16-bit unsigned integer. a roll-over in th2 does not set tf2, and will no t generate an interrupt. therefore, the timer interrupt does not have to be disabled when timer 2 is in the baud rate generator mode. if exen2 is set, a 1-to-0 transition on pin t2x will set the timer 2 interrupt flag exf2, but will not cause a reload from rcap2h and rcap2l to th2 and tl2. thus when timer 2 is in use as a baud rate generator, the pin t2x can be used as an extra external interrupt, if desired. when timer 2 is running (tr2 = 1) in a ?timer? function in the baud rate generator mode, firmware should not read or write th2 or tl2. under these conditions the results of a read or write may not be accurate. however, sfrs rcap2h and rcap2l may be read, but should not be written, because a write might overlap a reload and cause write and/or reload errors. timer 2 should be turned off (clear tr2) before accessing timer 2 or registers rcap2h and rcap2l, in this case. table 45 on page 96 shows commonly used baud rates and how they can be obtained from timer 2, with t2con = 34h.
standard 8032 timer/counters upsd34xx 96/293 table 45. commonly used baud rates generated from timer2 (t2con = 34h) f osc mhz desired baud rate timer 2 sfrs resulting baud rate baud rate deviation rcap2h (hex) rcap2l(hex) 40.0 115200 ff f5 113636 -1.36% 40.0 57600 ff ea 56818 -1.36% 40.0 28800 ff d5 29070 0.94% 40.0 19200 ff bf 19231 0.16% 40.0 9600 ff 7e 9615 0.16% 36.864 115200 ff f6 115200 0 36.864 57600 ff ec 57600 0 36.864 28800 ff d8 28800 0 36.864 19200 ff c4 19200 0 36.864 9600 ff 88 9600 0 36.0 28800 ff d9 28846 0.16% 36.0 19200 ff c5 19067 -0.69% 36.0 9600 ff 8b 9615 0.16% 24.0 57600 ff f3 57692 0.16% 24.0 28800 ff e6 28846 0.16% 24.0 19200 ff d9 19231 0.16% 24.0 9600 ff b2 9615 0.16% 12.0 28800 ff f3 28846 0.16% 12.0 9600 ff d9 9615 0.16% 11.0592 115200 ff fd 115200 0 11.0592 57600 ff fa 57600 0 11.0592 28800 ff f4 28800 0 11.0592 19200 ff ee 19200 0 11.0592 9600 ff dc 9600 0 3.6864 115200 ff ff 115200 0 3.6864 57600 ff fe 57600 0 3.6864 28800 ff fc 28800 0 3.6864 19200 ff fa 19200 0 3.6864 9600 ff f4 9600 0 1.8432 19200 ff fd 19200 0 1.8432 9600 ff fa 9600 0
upsd34xx standard 8032 timer/counters 97/293 figure 28. timer 2 in capture mode figure 29. timer 2 in auto-reload mode ai06625 f osc tf2 capture tr2 t2 pin control tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 exp2 control exen2 rcap2l rcap2h t2x pin timer 2 interrupt transition detector ai06626 f osc tf2 reload tr2 t2 pin control tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 exp2 control exen2 rcap2l rcap2h t2x pin timer 2 interrupt transition detector
standard 8032 timer/counters upsd34xx 98/293 figure 30. timer 2 in baud rate generator mode ai09605 f osc reload tr2 t2 pin control note: oscillator frequency is divided by 2, not 12 like in other timer modes. note: availability of additional external interrupt. tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 2 16 16 exf2 control exen2 rcap2l rcap2h t2x pin timer 2 interrupt tx clk rx clk timer 1 overflow smod rclk '1' '0' '1' '0' '1' '0' tclk transition detector
upsd34xx serial uart interfaces 99/293 21 serial uart interfaces upsd34xx devices provide two standard 8032 uart serial ports. ? the first port, uart0, is connected to pins rxd0 (p3.0) and txd0 (p3.1) ? the second port, uart1 is connected to pins rxd1 (p1.2) and txd1 (p1.3). uart1 can optionally be routed to pins p4.2 and p4.3 as described in section 17.1.4: alternate functions on page 74 . the operation of the two serial ports are the same and are controlled by two sfrs: scon0 ( table 47 on page 101 ) for uart0 scon1 ( table 48 on page 102 ) for uart1 each uart has its own data buffer accessed through an sfr listed below: sbuf0 for uart0, address 99h sbuf1 for uart1, address d9h when writing sbu0 or sbuf1, the data automatically loads into the associated uart transmit data register. when reading this sfr, data comes from a different physical register, which is the receive register of the associated uart. note: for simplicity in th e remaining uart discussions, the suff ix ?0? or ?1? will be dropped when referring to sfr registers and bits related to uart0 or uart1, since each uart interface has identical operation. example, sbuf0 an d sbuf1 will be referred to as just sbuf. each uart serial port can be full-duplex, meaning it can transmit and receive simultaneously. each uart is also receive-buffered, meaning it can commence reception of a second byte before a previously received byte has been read from the sbuf register. however, if the first byte still has not been read by the time reception of the second byte is complete, one of the bytes will be lost. 21.1 uart operation modes each uart can operate in one of four modes, one mode is synchronous, and the others are asynchronous as shown in table 46 on page 100 . 21.1.1 mode 0 mode 0 provides asynchronous, half-duplex operation. serial data is both transmitted, and received on the rxd pin. the txd pin outputs a shift clock for both transmit and receive directions, thus the mcu must be the master. eight bits are transmitted/received lsb first. the baud rate is fixed at 1/12 of f osc . 21.1.2 mode 1 mode 1 provides standard asynchronous, full-duplex communication using a total of 10 bits per data byte. data is transmitted through txd and received through rxd with: a start bit (logic '0'), eight data bits (lsb first), and a stop bit (logic '1'). upon receive, the eight data bits go into the sfr sbuf, and the stop bit goes into bit rb8 of the sfr scon. the baud rate is variable and derived from overflows of timer 1 or timer 2.
serial uart interfaces upsd34xx 100/293 21.1.3 mode 2 mode 2 provides asynchronous, full-duplex communication using a total of 11 bits per data byte. data is transmitted through txd and received through rxd with: a start bit (logic '0'); eight data bits (lsb first); a programmable 9th data bit; and a stop bit (logic '1'). upon transmit, the 9th data bit (from bit tb8 in scon) can be assigned the value of '0' or '1.' or, for example, the parity bit (p, in the psw) could be moved into tb8. upon receive, the 9th data bit goes into rb8 in scon, while the stop bit is ignored. the baud rate is programmable to either 1/32 or 1/64 of f osc . 21.1.4 mode 3 mode 3 is the same as mode 2 in all respects ex cept the baud rate is variable like it is in mode 1. in all four modes, transmission is initiated by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 by the condition ri = 0 and ren = 1. reception is initiated in the other modes by the incoming start bit if ren = 1. table 46. uart operating modes 21.1.5 multiprocessor communications modes 2 and 3 have a special provision for multiprocessor communications. in these modes, 9 data bits are received. the 9th one goes into bit rb8, then comes a stop bit. the port can be programmed such that when the st op bit is received, the uart interrupt will be activated only if bit rb8 = 1. this feature is enabled by setting bit sm2 in scon. a way to use this feature in multi-processor systems is as follows: when the master processor wants to transmit a block of data to one of several slaves, it first sends out an address byte which identifies the target slave. an address byte differs from a data byte in that the 9th bit is 1 in an address byte and 0 in a data byte. with sm 2 = 1, no slave will be interrupted by a data byte. an address byte, however, will interrupt all slaves, so that each slave can examine the received byte and see if it is being addressed. th e addressed slave will clear its sm2 bit and prepare to receive the data bytes that will be coming. t he slaves that were not being addressed leave their sm2 bits set and go on about their business, ignoring the coming data bytes. mode synchronization bits of sfr, scon baud clock data bits start/stop bits see figure sm0 sm1 0 synchronous 0 0 f osc /12 8 none figure 31 on page 105 1 asynchronous 0 1 timer 1 or timer 2 overflow 8 1 start, 1 stop figure 33 on page 107 2 asynchronous 1 0 f osc /32 or f osc /64 9 1 start, 1 stop figure 35 on page 109 3 asynchronous 1 1 timer 1 or timer 2 overflow 9 1 start, 1 stop figure 37 on page 110
upsd34xx serial uart interfaces 101/293 sm2 has no effect in mode 0, and in mode 1, sm2 can be used to check the validity of the stop bit. in a mode 1 reception, if sm2 = 1, the receive inte rrupt will not be activated unless a valid stop bit is received. 21.2 serial port control registers the sfr scon0 controls uart0, and scon1 controls uart1, shown in ta bl e 4 7 and ta bl e 4 8 . these registers contain not only the mode selection bits, but also the 9th data bit for transmit and receive (bits tb8 and rb8), and the uart interrupt flags, ti and ri. table 47. scon0: serial port uart0 control register (sfr 98h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sm0 sm1 sm2 ren tb8 rb8 ti ri bit symbol r/w definition 7 sm0 r,w serial mode select, see table 46 on page 100 . important, notice bit order of sm0 and sm1. [sm0:sm1] = 00b , mode 0 [sm0:sm1] = 01b , mode 1 [sm0:sm1] = 10b , mode 2 [sm0:sm1] = 11b , mode 3 6sm1r,w 5sm2r,w serial multiprocessor communication enable. mode 0 : sm2 has no effect but should remain 0. mode 1 : if sm2 = 0 then stop bit ignored. sm2 =1 then ri active if stop bit = 1. mode 2 and 3 : multiprocessor comm enable. if sm2=0, 9th bit is ignored. if sm2=1, ri active when 9th bit = 1. 4renr,w receive enable. if ren=0, uart reception disabled. if ren=1, reception is enabled 3tb8r,w tb8 is assigned to the 9th transmission bit in mode 2 and 3. not used in mode 0 and 1. 2rb8r,w mode 0 : rb8 is not used. mode 1 : if sm2 = 0, the rb8 is the level of the received stop bit. mode 2 and 3 : rb8 is the 9th data bit that was received in mode 2 and 3. 1tir,w transmit interrupt flag. causes interrupt at end of 8th bit time when transmitting in mode 0, or at beginning of stop bit transmission in other modes. must clear flag with firmware. 0rir,w receive interrupt flag. causes interrupt at end of 8th bit time when receiving in mode 0, or halfway through stop bit reception in other modes (see sm2 for exception). must clear this flag with firmware.
serial uart interfaces upsd34xx 102/293 table 48. scon1: serial port uart1 control register (sfr d8h, reset value 00h) 21.3 uart baud rates the baud rate in mode 0 is fixed: mode 0 baud rate = f osc / 12 the baud rate in mode 2 depends on the value of the bit smod in the sfr named pcon. if smod = 0 (default value), the baud rate is 1/64 the oscillator frequency, f osc . if smod = 1, the baud rate is 1/32 the oscillator frequency. mode 2 baud rate = (2 smod / 64) x f osc baud rates in modes 1 and 3 are determined by the timer 1 or timer 2 overflow rate. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sm0 sm1 sm2 ren tb8 rb8 ti ri bit symbol r/w definition 7 sm0 r,w serial mode select, see table 46 on page 100 . important, notice bit order of sm0 and sm1. [sm0:sm1] = 00b , mode 0 [sm0:sm1] = 01b , mode 1 [sm0:sm1] = 10b , mode 2 [sm0:sm1] = 11b , mode 3 6sm1r,w 5sm2r,w serial multiprocessor communication enable. mode 0 : sm2 has no effect but should remain 0. mode 1 : if sm2 = 0 then stop bit ignored. sm2 =1 then ri active if stop bit = 1. mode 2 and 3 : multiprocessor comm enable. if sm2=0, 9th bit is ignored. if sm2=1, ri active when 9th bit = 1. 4renr,w receive enable. if ren=0, uart reception disabled. if ren=1, reception is enabled 3tb8r,w tb8 is assigned to the 9th transmission bit in mode 2 and 3. not used in mode 0 and 1. 2rb8r,w mode 0 : rb8 is not used. mode 1 : if sm2 = 0, the rb8 is the level of the received stop bit. mode 2 and 3 : rb8 is the 9th data bit that was received in mode 2 and 3. 1tir,w transmit interrupt flag. causes interrupt at end of 8th bit time when transmitting in mode 0, or at beginning of stop bit transmission in other modes. must clear flag with firmware. 0rir,w receive interrupt flag. causes interrupt at end of 8th bit time when receiving in mode 0, or halfway through stop bit reception in other modes (see sm2 for exception). must clear this flag with firmware.
upsd34xx serial uart interfaces 103/293 21.3.1 using timer 1 to generate baud rates when timer 1 is used as the baud rate generator (bits rclk = 0, tclk = 0), the baud rates in modes 1 and 3 are determined by the timer 1 overflow rate and the value of smod as follows: mode 1,3 baud rate = (2 smod / 32) x (timer 1 overflow rate) the timer 1 interrupt should be disabled in this application. the timer itself can be configured for either ?timer? or ?counter? operation, and in any of its 3 running modes. in the most typical applications, it is configured for ?timer? operation, in the auto-reload mode (high nibble of the sfr tmod = 0010b). in that case the baud rate is given by the formula: mode 1,3 baud rate = (2 smod / 32) x (f osc / (12 x [256 ? (th1)])) ta bl e 4 9 lists various commonly used baud rates and how they can be obtained from timer 1. 21.3.2 using timer/counter 2 to generate baud rates see section 20.6.3: baud rate generator mode on page 94 . table 49. commonly used baud rates generated from timer 1 uart mode f osc mhz desired baud rate resultant baud rate baud rate deviation smod bit in pcon timer 1 c/t bit in tmod timer mode in tmod th1 reload value (hex) mode 0 max 40.0 3.33mhz 3.33mhz 0 x x x x mode 2 max 40.0 1250 k 1250 k 0 1 x x x mode 2 max 40.0 625 k 625 k 0 0 x x x modes 1 or 3 40.0 19200 18939 -1.36% 1 0 2 f5 modes 1 or 3 40.0 9600 9470 -1.36% 1 0 2 ea modes 1 or 3 36.0 19200 18570 -2.34% 1 0 2 f6 modes 1 or 3 33.333 57600 57870 0.47% 1 0 2 fd modes 1 or 3 33.333 28800 28934 0.47% 1 0 2 fa modes 1 or 3 33.333 19200 19290 0.47% 1 0 2 f7 modes 1 or 3 33.333 9600 9645 0.47% 1 0 2 ee modes 1 or 3 24.0 9600 9615 0.16% 1 0 2 f3 modes 1 or 3 12.0 4800 4808 0.16% 1 0 2 f3 modes 1 or 3 11.0592 57600 57600 0 1 0 2 ff modes 1 or 3 11.0592 28800 28800 0 1 0 2 fe modes 1 or 3 11.0592 19200 19200 0 1 0 2 fd modes 1 or 3 11.0592 9600 9600 0 1 0 2 fa
serial uart interfaces upsd34xx 104/293 21.4 more about uart mode 0 refer to the block diagram in figure 31 on page 105 , and timing diagram in figure 32 on page 105 . transmission is initiated by any instruction which writes to the sfr named sbuf. at the end of a write operation to sbuf, a 1 is loaded into the 9th position of the transmit shift register and tells the tx control unit to begin a transmission. transmission begins on the following mcu machine cycle, when the ?send? signal is active in figure 32 . send enables the output of the shift register to the alternate function on the port containing pin rxd, and also enables the shift clock signal to the alternate function on the port containing the pin, txd. at the end of eac h shift clock in which send is active, the contents of the transmit shift register are shifted to the right one position. as data bits shift out to the right, zeros come in from the left. when the msb of the data byte is at the output position of the shift register, then the '1' that was initially loaded into the 9th position, is just to the left of the msb, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift, then deactivate send, and then set the interrupt flag ti. both of these actions occur at s1p1. reception is initiated by the condition ren = 1 and ri = 0. at the end of the next mcu machine cycle, the rx control unit writes the bits 11111110 to the receive shift register, and in the next clock phase activates receive. receive enables the shift clock signal to the alternate function on the port containing the pin, txd. each pulse of shift clock moves the contents of the receive shift register one position to the left while receive is active. the value that comes in from the right is the value that was sampled at the rxd pin. as data bits come in from the right, 1s shift out to the left. when the 0 that was initially loaded into the right-most position arrives at the left-most position in the shift register, it flags the rx control unit to do one last shift, an d then it loads sbuf. after this, receive is cleared, and the receive interrupt flag ri is set. modes 1 or 3 3.6864 19200 19200 0 1 0 2 ff modes 1 or 3 3.6864 9600 9600 0 1 0 2 fe modes 1 or 3 1.8432 9600 9600 0 1 0 2 ff modes 1 or 3 1.8432 4800 4800 0 1 0 2 fe uart mode f osc mhz desired baud rate resultant baud rate baud rate deviation smod bit in pcon timer 1 c/t bit in tmod timer mode in tmod th1 reload value (hex)
upsd34xx serial uart interfaces 105/293 figure 31. uart mode 0, block diagram figure 32. uart mode 0, timing diagram 21.5 more about uart mode 1 refer to the block diagram in figure 33 on page 107 , and timing diagram in figure 34 on page 107 . transmission is initiated by any instruction wh ich writes to sbuf. at the end of a write operation to sbuf, a '1' is loaded into the 9th position of the transmit shift register and flags the tx control unit that a transmission is reques ted. transmission actually starts at the end ai06824 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift shift clock serial port interrupt f osc /12 ren r1 rx clock start tx clock start shift shift send receive t r cl ds q 7 6 5 4 3 2 1 0 rxd p3.0 alt input function rxd pin txd pin ai06825 write to sbuf send shift rxd (data out) txd (shift clock) ti write to scon ri receive shift rxd (data in) txd (shift clock) clear ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 d4 d5 d6 d7
serial uart interfaces upsd34xx 106/293 of the mcu the machine cycle following the next rollover in the divide-by-16 counter. thus, the bit times are synchronized to the divide-by-16 counter, not to the writing of sbuf. transmission begins with activati on of send which puts the start bit at pin txd. one bit time later, data is activated, which enables the output bit of the transmit shift register to pin txd. the first shift pulse occurs one bit time after that. as data bits shift out to the right, zeros are clocked in from the left. when the msb of the data byte is at the output position of the shift register, then the 1 that was initially loaded into the 9th position is just to the left of the msb, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift and then deactivates send, and sets the interrupt flag, ti. this occurs at the 10th divide-by-16 rollover after a write to sbuf. reception is initiated by a detected 1-to-0 transi tion at the pin rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide-by-16 counter is immediately reset, and 1ffh is written into the input shift register. resetting the divide-by-16 counter aligns its rollovers with the boundaries of the incoming bit times. the 16 states of the counter divide each bit time into 16ths. at the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. this is done for noise rejection. if the value accepted during the first bit time is not '0,' the receive circuits are reset and the unit goes back to looking for anot her '1'-to-'0' transition. this is to provide rejection of false start bits. if the start bit proves valid, it is shifted into the input shift register, and reception of the reset of the rest of the frame will proceed. as data bits come in from the right, '1s' shift out to the left. when the start bit arrives at the left-most position in the shift register (which in mode 1 is a 9-bit register), it flags the rx control unit to do one last shift, load sbuf and rb8, and set the receive interrupt flag ri. the signal to load sbuf and rb8, and to set ri, will be generated if, and onl y if, the following conditions are met at the time the final shift pulse is generated: 1. ri = 0, and 2. either sm2 = 0, or the received stop bit = 1. if either of these two conditions are not met, the received frame is irretrievably lost. if both conditions are met, the stop bit goes into rb8, the 8 data bits go into sbuf, and ri is activated. at this time, whether the above conditions are met or not, the unit goes back to looking for a '1'-to-'0' transition on pin rxd.
upsd34xx serial uart interfaces 107/293 figure 33. uart mode 1, block diagram figure 34. uart mode 1, timing diagram ai06826 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd pin data rx detector rxd pin 1-to-0 transition detector 16 sample 16 2 tb8 timer1 overflow timer2 overflow 0 01 1 01 tclk rclk smod ai06843 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit
serial uart interfaces upsd34xx 108/293 21.6 more about uart modes 2 and 3 for mode 2, refer to the block diagram in figure 35 on page 109 , and timing diagram in figure 36 on page 109 . for mode 3, refer to the block diagram in figure 37 on page 110 , and timing diagram in figure 38 on page 110 . keep in mind that the baud rate is programmable to either 1/32 or 1/64 of f osc in mode 2, but mode 3 uses a variable baud rate generated from timer 1 or timer 2 rollovers. the receive portion is exactly the same as in mode 1. the transmit portion differs from mode 1 only in the 9th bit of the transmit shift register. transmission is initiated by any instruction wh ich writes to sbuf. at the end of a write operation to sbuf, the tb8 bit is loaded into the 9th position of the transmit shift register and flags the tx control unit that a transmission is requested. transmission actually starts at the end of the mcu the machine cycle following the next rollover in the divide-by-16 counter. thus, the bit times are synchronized to the divide-by-16 counter, not to the writing of sbuf. transmission begins with activation of send which puts the start bit at pin txd. one bit time later, data is activated, which enables the output bit of the transmit shift register to pin txd. the first shift pulse occurs one bit time after that. the first shift clocks a '1' (the stop bit) into the 9th bit position of the shift register. there-after, only zeros are clocked in. thus, as data bits shift out to the right, zeros are clocked in from the left. when bit tb8 is at the output position of the shift register, then the stop bit is just to the left of tb8, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift and then deactivate send, and set the interrupt flag, ti. this occurs at the 11th divide-by 16 rollover after writing to sbuf. reception is initiated by a detected 1-to-0 transition at pin rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide-by-16 counter is immediately reset, and 1ffh is written to the input shift register. at the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. if the value accepted during the first bit time is not '0,' the receive circuits are reset and the unit goes back to looking for another '1'-to-'0' transition. if the start bit proves valid, it is shifted into the input shift regi ster, and reception of the rest of the frame will proceed. as data bits come in from the right, '1s' shift out to the left. when the start bit arrives at the left- most position in the shift register (which in modes 2 and 3 is a 9-bit register), it flags the rx control unit to do one last sh ift, load sbuf and rb8, and set the interrupt flag ri. the signal to load sbuf and rb8, and to set ri, will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: 1. ri = 0, and 2. either sm2 = 0, or the received 9th data bit = 1. if either of these conditions is not met, the received frame is irretrievably lost, and ri is not set. if both conditions are met, the received 9th data bit goes into rb8, and the first 8 data bits go into sbuf. one bit time later, whether the above conditions were met or not, the unit goes back to looking for a '1'-to-'0' transition on pin rxd.
upsd34xx serial uart interfaces 109/293 figure 35. uart mode 2, block diagram figure 36. uart mode 2, timing diagram ai06844 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd pin data rx detector rxd pin 1-to-0 transition detector 16 sample 16 2 tb8 f osc /32 01 smod ai06845 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit tb8 d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit rb8 stop bit generator
serial uart interfaces upsd34xx 110/293 figure 37. uart mode 3, block diagram figure 38. uart mode 3, timing diagram ai06846 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd pin data rx detector rxd pin 1-to-0 transition detector 16 sample 16 2 tb8 timer1 overflow timer2 overflow 0 01 1 01 tclk rclk smod ai06847 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit tb8 d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit rb8 stop bit generator
upsd34xx irda interface 111/293 22 irda interface upsd34xx devices provide an in ternal irda interface that w ill allow the connection of the uart1 serial interface directly to an external infrared transceiver device. the irda interface does this by automatically shortening the pulses transmitted on uart1?s txd1 pin, and stretching the incoming pulses received on the rxd1 pin. reference figures 39 and 40 . when the irda interface is enabled, the outpu t signal from uart1?s transmitter logic on pin txd1 is compliant with the irda physical laye r link specification v1.4 (www.irda.org) operating from 1.2k bps up to 115.2k bps. the pulses received on the rxd1 pin are stretched by the irda interface to be recognized by uart1?s receiver logic, also adhering to the irda specification up to 115.2k bps. note: in figure 40 a logic '0' in the serial data stream of a uart frame corresponds to a logic high pulse in an ir frame. a logic '1' in a uart frame corresponds to no pulse in an ir frame. figure 39. irda interface figure 40. pulse shaping by the irda interface ua rt1 irda inter f ac e txd rxd upsd34xx ir da transceiver txd1-irda rx d1- ir da sirclk ai10437 start bit 0101 11 1 00 0 stop bit uart frame data bits bit time pulse width = 3/16 bit time start bit 0101 11 1 00 0 stop bit uart frame ir frame ir frame data bits ai10438
irda interface upsd34xx 112/293 the uart1 serial channel can operate in one of four different modes as shown in ta b l e 4 6 on page 100 in section 21: serial uart interfaces on page 99 . however, when uart1 is used for irda communication, uart1 must operate in mode 1 only, to be compatible with irda protocol up to 115.2k bps. the irda in terface will support baud rates generated from timer 1 or timer 2, just like standard uart serial communication, but with one restriction. the transmit baud rate and receive baud rate must be the same (cannot be different rates as is allowed by standard uart communications). the irda interface is disabled after a reset and is enabled by setting the irdaen bit in the sfr named irdacon ( table 50 on page 112 ). when irda is disabled, the uart1's rxd and txd signals will bypass the internal irda logi c and instead they are routed directly to the pins rxd1 and txd1 respectively. when irda is enabled, the irda pulse shaping logic is active and resides between uart1 and the pins rxd1 and txd1 as shown in figure 39 on page 111 . 22.1 baud rate selection the irda standard only supports 2.4, 9.6, 19.2, and 115.2kbps. table 52 on page 113 informs the irda interface of the baud rate of uart#1 so that it can perform pulse modulation properly. it may not be necessary to implement the br[3:0] bits in the irdacon register if the irda interface obtains the proper timing from uart#1. table 50. irdacon register bit definition (sfr ceh, reset value 0fh) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? irdaen pulse cdiv4 cdiv3 cdiv2 cdiv1 cdiv0 bit symbol r/w definition 7 ? ? reserved 6 irdaen rw irda enable 0 = irda interface is disabled 1 = irda is enabled, uart1 outputs are disconnected from port 1 (or port 4) 5pulserw irda pulse modulation select 0 = 1.627s 1 = 3/16 bit time pulses 4-0 cdiv[4:0] rw specify clock divider (see table 53 on page 114 )
upsd34xx irda interface 113/293 table 51. baud rate selection register (sfr xxh, reset value xxh) table 52. baud rate of uart#1 for irda interface 22.2 pulse width selection the irda interface has two ways to modulate the standard uart1 serial stream: 1. an irda data pulse will have a constant pulse width for any bit time, regardless of the selected baud rate. 2. an irda data pulse will have a pulse width that is proportional to th e the bit time of the selected baud rate. in this case, an irda data pulse width is 3/16 of its bit time, as shown in figure 40 on page 111 . the pulse bit in the sfr named irdacon det ermines which method above will be used. according to the irda physical layer specification, for all baud rates at 115.2k bps and below, the minimum data pulse width is 1.41s. for a baud rate of 115.2k bps, the maximum pulse width 2.23s. if a constant pulse width is to be used for all baud rates (pulse bit = 0), the ideal general pulse width is 1.63s, derived from the bit time of the fastest baud rate (8.68s bit time for 115.2k bps rate), multiplied by the proportion, 3/16. bit symbol r/w definition 7:4 br[3:0] r,w specify baud rate (see ta bl e 5 2 ) 3:2 pulse r,w irda pulse modulation select 0 = 3/16 bit time pulses (not recommended) 1 = 1.627s 1:0 irdaen r,w 0 = irda interface is disabled 1 = irda is enabled, uart#1 outputs are disconnected from port 1 (or port 4) br3 br2 br1 br0 baud rate (kbps) 0000115.2 000157.5 001038.4 001119.2 010014.4 010112.8 01109.6 01117.2 10004.8 10013.6 10102.4 10111.8 11001.2
irda interface upsd34xx 114/293 to produce this fixed data pulse width when the pulse bit = 0, a prescaler is needed to generate an internal reference clock, sirclk, shown in figure 39 on page 111 . sirclk is derived by dividing the os cillator clock frequency, f osc, using the five bits cdiv[4:0] in the sfr named irdacon. a divisor must be chosen to produce a frequ ency for sirclk that lies between 1.34 mhz and 2.13 mhz, but it is best to choose a divisor value that produces sirclk frequency as close to 1.83mhz as possible, because sirclk at 1.83mhz will produce an fixed irda data pulse width of 1.63s. ta b l e 5 3 provides recommended values for cdiv[4:0] based on several different values of f osc . for reference, sirclk of 2.13mhz will generate a fixed irda data pulse width of 1.41s, and sirclk of 1.34mhz will generate a fixed data pulse width of 2.23s. table 53. recommended cdiv[4:0] values to generate sirclk (default cdiv[4:0] = 0fh, 15 decimal) note: 1 when pulse bit = 0 (fixed data puls e width), this is minimum recommended f osc because cdiv[4:0] must be 4 or greater. f osc (mhz) value in cdiv[4:0] resulting f sirclk (mhz) 40.00 16h, 22 decimal 1.82 36.864, or 36.00 14h, 20 decimal 1.84, or 1.80 24.00 0dh, 13 decimal 1.84 11.059, or 12.00 06h, 6 decimal 1.84, or 2.00 7.3728 (1) 04h, 4 decimal 1.84
upsd34xx i 2 c interface 115/293 23 i 2 c interface upsd34xx devices support one serial i 2 c interface. this is a two-wire communication channel, having a bi-directional data signal (sda, pin p3.6) and a clock signal (scl, pin p3.7) based on open-drain line drivers, requiring external pull-up resistors, r p , each with a typical value of 4.7k ? (see figure 41 ). 23.1 i 2 c interface main features byte-wide data is transferred, msb first, between a master device and a slave device on two wires. more than one bus master is allowed, but only one master may control the bus at any given time. data is not lost when another master requests the use of a busy bus because i 2 c supports collision detection and arbitration. the bus master initiates all data movement and generates the clock that permits the transfer. once a transfer is initiated by the master, any device addressed is considered a slave. automatic clock synchronization allows i 2 c devices with different bit rates to communicate on the same physical bus. a single device can play the role of master or slave, or a single device can be a slave only. each slave device on the bus has a unique address, and a general broadcast address is also available. a master or slave device has the ability to sus pend data transfers if the device needs more time to transmit or receive data. this i 2 c interface has the following features: serial i/o engine (sioe): serial/parallel conversion; bus arbitration; clock generation and synchronization; and handshaking are all performed in hardware interrupt or polled operation multi-master capability 7-bit addressing supports standard speed i 2 c (scl up to 100khz), fast mode i 2 c (101khz to 400khz), and high-speed mode i 2 c (401khz to 833khz) figure 41. typical i 2 c bus configuration note: 1 for 3.3v system, connect r p to 3.3v v cc . for 5.0v system, connect r p to 5.0v v dd . i 2 c bus sda scl r p r p v cc or v dd (1) device with i 2 c interface device with i 2 c interface sda/p3.6 scl/p3.7 upsd34xx(v) device with i 2 c interface ai09623b
i 2 c interface upsd34xx 116/293 23.2 communication flow i 2 c data flow control is based on the fact that all i 2 c compatible devices will drive the bus lines with open-drain (or open-collector) line drivers pulled up with external resistors, creating a wired-and situation. this means that either bus line (sda or scl) will be at a logic '1' level only when no i 2 c device is actively driving the line to logic '0.' the logic for handshaking, arbitration, sync hronization, and collis ion detection is implemented by each i 2 c device having: 1. the ability to hold a line low against the w ill of the other devices who are trying to assert the line high. 2. the ability of a device to det ect that another device is dr iving the line low against its will. assert high means the driver releases the line and external pull-ups passively raise the signal to logic '1.' holding lo w means the open-d rain driver is actively pulling the signal to ground for a logic '0.' for example, if a slave device cannot transmit or receive a byte because it is distracted by and interrupt or it has to wait for some process to complete, it can hold the scl clock line low. even though the ma ster device is generating the sc l clock, the master will sense that the slave is holding the scl line low against the will of the master, indica ting that the master must wait until the slave releases scl before proceeding with the transfer. another example is when two master devices try to put information on the bus simultaneously, the first one to release the sda data line looses arbitration while the winner continues to hold sda low. two types of data transfers are possible with i 2 c depending on the r/w bit, see figure 42 on page 117 . 1. data transfer from master transmitter to slave receiver (r/w = 0). in this case, the master generates a start condition on the bus and it generates a clock signal on the scl line. then the master transmits the first byte on the sda line containing the 7-bit slave address plus the r/w bit. the slave who owns th at address will re spond with an acknowledge bit on sda, and all other slav e devices will not respond. next, the master will transmit a data byte (or bytes) that th e addressed slave must receive. the slave will return an acknowledge bit after each data byte it successfully receives. after the final byte is transmitted by the master, the master will generate a stop condition on the bus, or it will generate a re-start cond iton and begin the next transfer. there is no limit to the number of bytes that can be transmitted during a transfer session. 2. data transfer from slave transmitter to master receiver (r/w = 1). in this case, the master generates a start condition on the bus and it generates a clock signal on the scl line. then the master transmits the first byte on the sda line containing the 7-bit slave address plus the r/w bit. the slave who owns th at address will re spond with an acknowledge bit on sda, and all other sl ave devices will not respond. next, the addressed slave will transmit a data byte (o r bytes) to the master. the master will return an acknowledge bit after each data byte it successfully receives, unless it is the last byte the master desire s. if so, the master will not acknowledge the last byte and from this, the slave knows to stop transmitti ng data bytes to the master. the master will then generate a stop condition on the bu s, or it will generate a re-start conditon and begin the next transfer. there is no limit to the number of bytes that can be transmitted during a transfer session.
upsd34xx i 2 c interface 117/293 a few things to know related to these transfers: either the master or slave device can hold the scl clock line low to indicate it needs more time to handle a byte transfer. an indefinite holding period is possible. a start condition is generated by a master and recognized by a slave when sda has a 1-to-0 transition while scl is high ( figure 42 on page 117 ). a stop condition is generated by a master and recognized by a slave when sda has a 0-to1 transition while scl is high ( figure 42 on page 117 ). a re-start (repeated start) condition generated by a master can have the same function as a stop condition when starting another data transfer immediately following the previous data transfer ( figure 42 on page 117 ). when transferring data, the logic level on th e sda line must remain stable while scl is high, and sda can change only while scl is low. however, when not transferring data, sda may change state while scl is high, which creates the start and stop bus conditions. an acknowlegde bit is generated from a master or a slave by driving sda low during the ?ninth? bit time, just following each 8-bit byte that is transfered on the bus ( figure 42 on page 117 ). a non-acknowledge occurs when sda is asserted high during the ninth bit time. all byte transfers on the i 2 c bus include a 9th bit time reserved for an acknowlege (ack) or non-acknowledge (nack). an additional master device that desires to control the bus should wait until the bus is not busy before generating a start condition so that a possible slave operation is not interrupted. if two master devices both try to generate a start condition simultaneously, the master who looses arbitration will switch immediately to slave mode so it can recoginize its own slave address should it appear on the bus. figure 42. data transfer on an i 2 c bus 23.3 operating modes the i 2 c interface supports four operating modes: master-transmitter master-receiver slave-transmitter slave-receiver msb 7-bit slave address read/write indicator acknowledge bits from receiver start condition clock can be held low to stall transfer. repeated if more data bytes are transferred. repeated start condition stop condition 12 789 3-6 1 2 9 3-8 msb ack ack nack r/w ai09625
i 2 c interface upsd34xx 118/293 the interface may operate as either a master or a slave within a given application, controlled by firmware writing to sfrs. by default after a reset, the i 2 c interface is in master receiver mode, and the sda/p3.6 and scl/p3.7 pins default to gpio input mode, high impedance, so there is no i 2 c bus interference. before using the i 2 c interface, it must be initialized by firmware, and the pins must be configured. this is discussed in section 23.13: i 2 c operating sequences on page 127 . 23.4 bus arbitration a master device always samples the i 2 c bus to ensure a bus line is high whenever that master is asserting a logic 1. if the line is low at that time, the master recognizes another device is overriding its own transmission. a master may start a transfer only if the i 2 c bus is not busy. however, it is possible that two or more masters may generate a start condition simultaneously. in this case, arbitration takes place on the sda line each time scl is high. the master that first senses that its bus sample does not correspond to what it is drivin g (sda line is low while it is asserting a high) will immediately change from mast er-transmitter to slave-rece iver mode. the arbitration process can carry on for many bit times if both masters are addressing the same slave device, and will continue into the data bits if both masters are trying to be master- transmitter. it is also possible for arbitration to carry on into the acknowledge bits if both masters are trying to be master-receiver. because address and data information on the bus is determined by the winning master, no information is lost during the arbitration process. 23.5 clock synchronization clock synchronization is used to synchronize arbitrating masters, or used as a handshake by a devices to slow down the data transfer. 23.5.1 clock sync dur ing arbitration during bus arbitration between competing masters, master_x, with the longest low period on scl, will force master_y to wait until master _x finishes its low period before master_y proceeds to assert its high period on scl. at this point, both masters begin asserting their high period on scl simultaneously , and the master with the sh ortest high period will be the first to drive scl for the next low period. in this scheme, the master with the longest low scl period paces low times, and the master with the shortest high scl period paces the high times, making synchronized arbitration possible. 23.5.2 clock sync during handshaking this allows receivers in different devices to handle various transfer rates, either at the byte- level, or bit-level. at the byte-level, a device may pause the transfer between bytes by holding scl low to have time to store the latest received byte or fetch the next byte to transmit. at the bit-level, a slave device may extend the low period of scl by holding it low. thus the speed of any master device will adapt to the internal oper ation of the slave.
upsd34xx i 2 c interface 119/293 23.6 general call address a general call (gc) occurs when a master-transmitter initiates a transfer containing a slave address of 0000000b, and the r/w bit is logic 0. all slave devices capable of responding to this broadcast message will acknowledge the gc si multaneously and then behave as a slave-receiver. the next byte transmitted by the master will be accepted and acknowledged by all slaves capable of handling the special data bytes. a slave that cannot handle one of these data bytes must ignore it by not acknowledging it. the i 2 c specification lists the possible meanings of the special bytes that follow the first gc address byte, and the actions to be taken by the slave device(s) upon receiving them. a common use of the gc by a master is to dynamically assign device addr esses to slave devices on the bus capable of a programmable device address. the upsd34xx can generate a gc as a master-transmitter, and it can receive a gc as a slave. when receiving a gc address (00h), an interrupt will be generated so firmware may respond to the special gc data bytes if desired. 23.7 serial i/o engine (sioe) at the heart of the i 2 c interface is the hardware sioe, shown in figure 43 . the sioe automatically handles low-level i 2 c bus protocol (data shifting, handshaking, arbitration, clock generation and synchronization) and it is controlled and monitored by five sfrs. the five sfrs shown in figure 43 are: s1con - interface control ( table 54 on page 121 ) s1sta - interface status ( table 56 on page 123 ) s1dat - data shift register ( table 57 on page 124 ) s1adr - device address ( table 58 on page 124 ) s1setup - sampling rate ( table 59 on page 125 )
i 2 c interface upsd34xx 120/293 figure 43. i 2 c interface sioe block diagram open- drain output input open- drain output input comparator s1setup - sample rate control (start condition) s1sta - interface status s1con - interface control ack bit scl / p3.7 timing and control clock generation arbitration and sync periph clock (f osc ) sda / p3.6 8032 mcu bus intr to 8032 s1dat - shift register serial data in serial data out shift direction 8 8 8 8 8 7 7 b0 b7 s1adr - device address b7 b0 ai09626
upsd34xx i 2 c interface 121/293 23.8 i 2 c interface control register (s1con) table 54. serial control register s1con (sfr dch, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 cr2 eni1 sta sto addr aa cr[1:0] bit symbol r/w function 7cr2r,w this bit, along with bits cr1 and cr0, determine the scl clock frequency (f scl ) when sioe is in master mode. these bits create a clock divisor for f osc . see ta b l e 5 5 . 6eni1r,w i 2 c interface enable 0 = sioe disabled, 1 = sioe enabled. when disabled, both sda and scl signals are in high impedance state. 5star,w start flag. when set, master mode is entered and sioe generates a start condition only if the i 2 c bus is not busy. when a start condition is detected on the bus, the sta flag is cleared by hardware. when the sta bit is set during an interrupt service, the start condition will be generated after the interrupt service. 4stor,w stop flag when sto is set in master mode, the sioe generates a stop condition. when a stop condition is detected, the sto flag is cleared by hardware. when the sto bit is set during an interrupt service, the stop condition will be generated after the interrupt service. 3 addr r,w this bit is set when an address byte received in slave mode matches the device address programmed into the s1adr register. the addr bit must be cleared with firmware. 2aar,w assert acknowledge enable if aa = 1, an acknowledge signal (low on sda) is automatically returned during the acknowledge bit-time on the scl line when any of the following three events occur: 1. sioe in slave mode receives an address that matches contents of s1adr register 2. a data byte has been received while sioe is in master receiver mode 3. a data byte has been received while sioe is a selected slave receiver when aa = 0, no acknowledge is returned (high on sda during acknowledge bit-time). 1, 0 cr1, cr0 r,w these bits, along with bit cr2, determine the scl clock frequency (f scl ) when sioe is in master mode. these bits create a clock divisor for f osc . see ta b l e 5 5 for values.
i 2 c interface upsd34xx 122/293 table 55. selection of the scl frequency in master mode based on f osc examples note: 1 these values are beyond the bit rate supported by upsd34xx. 23.9 i 2 c interface status register (s1sta) the s1sta register provides status regarding immediate activity and the current state of operation on the i 2 c bus. all bits in this register are read-only except bit 5, intr, which is the interrupt flag. 23.9.1 interrupt conditions if the i 2 c interrupt is enabled (ei 2 c = 1 in sfr named iea, a nd ea =1 in sfr named ie), and the sioe is initialized, then an interrupt is automatically generated when any one of the following five events occur: when the sioe receives an address that matches the contents of the sfr, s1adr. requirements: sioe is in slave mode, and bit aa = 1 in the sfr s1con. when the sioe receives general call address. requirments: sioe is in slave mode, bit aa = 1 in the sfr s1con when a complete data byte has been received or transmitted by the sioe while in master mode. the interrupt will occur ev en if the master lo oses arbitration. when a complete data byte has been received or transmitted by the sioe while in selected slave mode. a stop condition on the bus has been recogn ized by the sioe while in selected slave mode. selected slave mode means the device address sent by the master device at the beginning of the current data transfer matched the address stored in the s1adr register. if the i 2 c interrupt is not enabled, the mcu may poll the intr flag in s1sta. cr2 cr1 cr0 f osc divided by: bit rate (khz) @ f osc 12mhz f osc 24mhz f osc 36mhz f osc 40mhz f osc 0 0 0 32 375 750 x (1) x (1) 0 0 1 48 250 500 750 833 0 1 0 60 200 400 600 666 0 1 1 120 100 200 300 333 1 0 0 240 50 100 150 166 1 0 1 480 25 50 75 83 1 1 0 960 12.5 25 37.5 41 1 1 1 1920 6.25 12.5 18.75 20
upsd34xx i 2 c interface 123/293 table 56. s1sta: i 2 c interface status register (sfr ddh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 gc stop intr tx_mode bbusy blost ack_resp slv bit symbol r/w function 7gcr general call flag gc = 1 if the general call address of 00h was received when sioe is in slave mode, and gc is cleared by a start or stop condition on the bus. if the sioe is in master mode when gc = 1, the bus lost condition exists, and blost = 1. 6stopr stop flag stop = 1 while sioe detects a stop condition on the bus when in master or slave mode. 5intrr,w interrupt flag intr is set to 1 by any of the five i 2 c interrupt conditions listed above. intr must be cleared by firmware. 4tx_moder transmission mode flag tx_mode = 1 whenever the sioe is in master-transmitter or slave-transmitter mode. tx_mode = 0 when sioe is in any receiver mode. 3bbusyr bus busy flag bbusy = 1 when the i 2 c bus is in use. bbusy is set by the sioe when a start condition exists on the bus and bbusy is cleared by a stop condition. 2blostr bus lost flag blost is set when the sioe is in master mode and it looses the arbitration process to another master device on the bus. 1ack_resp r not acknowledge response flag while sioe is in transmitter mode: ? after sioe sends a byte, ack_resp = 1 whenever the external i 2 c device receives the byte, but that device does not assert an ackowledge signal (external device asserted a high on sda during the acknowledge bit-time). ? after sioe sends a byte, ack_resp = 0 whenever the external i 2 c device receives the byte, and that device does assert an ackowledge signal (external device drove a low on sda during the acknowledge bit-time) note: if sioe is in master-transmitter mode, and ack_resp = 1 due to a slave-transmitter not sending an acknowledge, a stop condition will not automat ically be generated by the sioe. the stop condition must be generated with s1con.sto = 1. 0slvr slave mode flag slv = 1 when the sioe is in slave mode. slv = 0 when the sioe is in master mode (default).
i 2 c interface upsd34xx 124/293 23.10 i 2 c data shift register (s1dat) the s1adr register ( ta b l e 5 7 ) holds a byte of serial data to be transmitted or it holds a serial byte that has just b een received. the mcu may access s1dat while the sioe is not in the process of shifting a byte (the intr flag indicates shifting is complete). while transmitting, bytes are shifted out msb first, and when receiving, bytes are shifted in msb first, through the acknowledge bit register as shown in figure 43 on page 120 . 23.10.1 bus wait condition after the sioe finishes receiving a byte in re ceive mode, or transmitting a byte in transmit mode, the intr flag (in s1sta) is set and autom atically a wait condition is imposed on the i 2 c bus (scl held low by sioe). in transmit m ode, this wait condition is released as soon as the mcu writes any byte to s1dat. in receive mode, the wait condition is released as soon as the mcu reads the s1dat register. this method allows the user to handle transmit and receive operations within an interrupt service routine. the sioe will automatically stall the i 2 c bus at the appropriate time, giving the mcu time to get the next byte ready to transmit or time to read the byte that was just received. table 57. s1dat: i 2 c data shift register (sfr deh, reset value 00h) 23.11 i 2 c address register (s1adr) the s1adr register ( ta b l e 5 8 ) holds the 7-bit device address used when the sioe is operating as a slave. when the sioe receiv es an address from a master, it will compare this address to the contents of s1adr, as shown in figure 43 on page 120 . if the 7 bits match, the intr interrupt flag (in s1sta) is set, and the addr bit (in s1con) is set. the sioe cannot modify the contents s1adr, and s1adr is not used during master mode. table 58. s1adr: i 2 c address register (sfr dfh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 s1dat[7:0] bit symbol r/w function 7:0 s1dat[7:0] r/w holds the data byte to be transmitted in transmit mode, or it holds the data byte received in receiver mode. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sla6 sla5 sla4 sla3 sla2 sla1 sla0 ? bit symbol r/w function 7:1 sla[6:0] r/w stores desired 7-bit device address, used when sioe is in slave mode. 0 ? ? not used
upsd34xx i 2 c interface 125/293 23.12 i 2 c start sample set ting (s1setup) the s1setup register ( ta bl e 5 9 ) determines how many times an i 2 c bus start condition will be sampled before the sioe validates the start condition, giving the sioe the ability to reject noise or illegal transmissions. because the minimum duration of an start condition varies with i 2 c bus speed (f scl ), and also because the upsd34xx may be operated with a wide variety of frequencies (f osc ), it is necessary to scale the number of samples per start condition based on f osc and f scl . in slave mode, the sioe recognizes the beginning of a start condition when it detects a '1'-to-'0' transition on the sda bus line while the scl line is high (see figure 42 on page 117 ). the sioe must then validate the star t condition by samplin g the bus lines to ensure sda remains low and scl remains high for a minimum amount of hold time, t hldsta . once validated, the sioe begins receiving the address byte that follows the start condition. if the en_ss bit (in the s1setup register) is not set, then the sioe will sample only once after detecting the '1'-to-'0' transition on sda. this single sample is taken 1/f osc seconds after the initial 1-to-0 transition was detected. however, more samples should be taken to ensure there is a valid start condition. to take more samples, the sioe should be initialized such that the en_ss bit is set, and a value is written to the smpl_set[6:0] field of the s1setup register to specify how many samples to take. the goal is to take a good number of samples during the minimum start condition hold time, t hldsta , but no so many samples th at the bus will be sampled after t hldsta expires. table 60 on page 126 describes the relationship between the contents of s1setup and the resulting number of i 2 c bus samples that sioe will take a fter detecting the 1-to-0 transition on sda of a start condition. important note: keep in mind that the time between samples is always 1/f osc . the minimum start condition hold time, t hldsta , is different for the three common i 2 c speed categories per table 61 on page 126 . table 59. s1setup: i 2 c start condition sample setup register (sfr dbh, reset value 00h) note: 1 sampling scl and sda lines begins after '1'- to-'0' transition on sda occurred while scl is high. time between samples is 1/f osc . bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 en_ss smpl_set[6:0] bit symbol r/w function 7en_ssr/w enable sample setup en_ss = 1 will force the sioe to sample (1) a start condition on the bus the number of time s specified in smpl_set[6:0]. en_ss = 0 means the sioe will sample (1) a start condition only one time, regardless of the contents of smpl_set[6:0]. 6:0 smpl_set [6:0] ? sample setting specifies the number of bus samples (1) taken during a start condition. see ta bl e 6 0 for values.
i 2 c interface upsd34xx 126/293 table 60. number of i 2 c bus samples taken after 1-to-0 transition on sda (start condition) table 61. start condition hold time note: 1 833khz is maximum for upsd34xx devices. ta bl e 6 2 provides recommended settings for s1setup based on various combinations of f osc and f scl . note that the ?total sample period? times in table 61 on page 126 are typically slightly less than the mi nimum start condition hold time, t hldsta for a given i 2 c bus speed. important note: the scl bit rate f scl must first be determined by bits cr[2:0] in the sfr s1con before a value is chosen fo r smpl_set[6:0] in the sfr s1setup. contents of s1setup resulting value for s1setup resulting number of samples taken after 1-to-0 on sda line ss_en bit smpl_set[6:0] 0 xxxxxxxb 00h (default) 1 1 0000000b 80h 1 1 0000001b 81h 2 1 0000010b 82h 3 ... ... ... ... 1 0001011b 8bh 12 1 0010111b 97h 24 ... ... ... ... 1 1111111b ffh 128 i 2 c bus speed range of i 2 c clock speed (f scl ) minimum start condition hold time ( t hldsta ) standard up to 100khz 4000ns fast 101khz to 400khz 600ns high 401khz to 833khz (1) 160ns
upsd34xx i 2 c interface 127/293 table 62. s1setup examples for various i 2 c bus speeds and oscillator frequencies note: 1 not compatible with high speed i 2 c. 23.13 i 2 c operating sequences the following pseudo-code explains hardware control for these i 2 c functions on the upsd34xx: initialize the interface function as master-transmitter function as master-receiver function as slave-transmitter function as slave-receiver interrupt service routine full c code drivers for the upsd34xx i 2 c interface, and other interfaces are available from the web at www.st.com\psm. initialization after a upsd34xx reset ensure pins p3.6 and p3.7 are gpio inputs ? sfr p3.7 = 1 and sfr p3.6 = 1 configure pins p3.6 and p3.7 as i2c ? sfr p3sfs.6 = 1 and p3sfs.7 = 1 i 2 c bus speed, f scl parameter oscillator frequency, f osc 6 mhz 12 mhz 24 mhz 33 mhz 40 mhz standard recommended s1setup value 93h a7h cfh eeh ffh number of samples 20 40 80 111 128 time between samples 166.6ns 83.3ns 41.6ns 30ns 25ns total sampled period 3332ns 3332ns 3332ns 3333ns 3200ns fast recommended s1setup value 82h 85h 8bh 90h 93h number of samples 3 6 12 17 20 time between samples 166.6ns 83.3ns 41.6ns 30ns 25ns total sampled period 500ns 500ns 500ns 510ns 500ns high recommended s1setup value (note 1) 80 82 83 84 number of samples - 1345 time between samples - 83.3ns 41.6ns 30ns 25ns total sampled period - 83.3 125ns 120ns 125ns
i 2 c interface upsd34xx 128/293 set i2c clock prescaler to determine fscl ? sfr s1con.cr[2:0] = desired scl freq. set bus start condition sampling ? sfr s1setup[7:0] = number of samples enable individual i2c interrupt and set priority ? sfr iea.i2c = 1 ? sfr ipa.i2c = 1 if high priority is desired set the device address for slave mode ? sfr s1adr = xxh, desired address enable sioe (as slave) to return an ack signal ? sfr s1con.aa = 1 master-transmitter disable all interrupts ? sfr ie.ea = 0 set pointer to global data xmit buffer, set count ? *xmit_buf = *pointer to data ? buf_length = number of bytes to xmit set global variables to indicate master-xmitter ? i2c_master = 1, i2c_xmitter = 1 disable master from returning an ack ? sfr s1con.aa = 0 enable i2c sioe ? sfr s1con.ini1 = 1 transmit address and r/w bit = 0 to slave ? is bus not busy? (sfr s1sta.bbusy = 0?) ? sfr s1dat[7:0] = load slave address & feh ? sfr s1con.sta = 1, send start on bus enable all interrupts and go do something else ? sfr ie.ea = 1 master-receiver disable all interrupts ? sfr ie.ea = 0 set pointer to global data recv buffer, set count ? *recv_buf = *pointer to data ? buf_length = number of bytes to recv
upsd34xx i 2 c interface 129/293 set global variables to indicate master-xmitter ? i2c_master = 1, i2c_xmitter = 0 disable master from returning an ack ? sfr s1con.aa = 0 enable i2c sioe ? sfr s1con.ini1 = 1 transmit address and r/w bit = 1 to slave ? is bus not busy? (sfr s1sta.bbusy = 0?) ? sfr s1dat[7:0] = load slave address # 01h ? sfr s1con.sta = 1, send start on bus enable all interrupts and go do something else ? sfr ie.ea = 1 slave-transmitter disable all interrupts ? sfr ie.ea = 0 set pointer to global data xmit buffer, set count ? *xmit_buf = *pointer to data ? buf_length = number of bytes to xmit set global variables to indicate master-xmitter ? i2c_master = 0, i2c_xmitter = 1 enable sioe ? sfr s1con.ini1 = 1 prepare to xmit first data byte ? sfr s1dat[7:0] = xmit_buf[0] enable all interrupts and go do something else ? sfr ie.ea = 1 slave-receiver disable all interrupts ? sfr ie.ea = 0 set pointer to global data recv buffer, set count ? *recv_buf = *pointer to data ? buf_length = number of bytes to recv set global variables to indicate master-xmitter ? i2c_master = 0, i2c_xmitter = 0 enable sioe ? sfr s1con.ini1 = 1
i 2 c interface upsd34xx 130/293 enable all interrupts and go do something else ? sfr ie.ea = 1 23.13.1 interrupt ser vice routine (isr) a typical i 2 c interrupt service routine would handle a interrupt for any of the four combinations of master/slave and transmitter/receiver. in the example routines above, the firmware sets global variables, i2c_master and i2c_xmitter, before enabling interrupts. these flags tell the isr which one of the four cases to process. following is pseudo-code for high-level steps in the i 2 c isr: begin i2c isr : clear i2c interrupt flag: ? s1sta.intr = 0 read status of sioe, put in to variable, status ? status = s1sta read global variables that determine the mode ? mode <= (i2c_master, i2c_slave) if mode is master-transmitter bus arbitration lost? (status.blost=1?) if yes, arbitration was lost: ? s1dat = dummy, write to release bus ? exit isr, sioe will switch to slave recv mode if no, arbitration was not lost, continue: ack recvd from slave? (status.ack_resp=0?) if no, an ack was not received: ? s1con.sto = 1, set stop bus condition ? ? s1dat = dummy, write to release bus ? exit isr if yes, ack was received, then continue: ? s1dat = xmit_buf[buffer_index], transmit byte was that the last byte of data to transmit? if no, it was not the last byte, then: ? exit isr, transmit next byte on next interrupt if yes, it was the last byte, then: ? s1con.sto = 1, set stop bus condition ? s1dat = dummy, write to release bus ? exit isr
upsd34xx i 2 c interface 131/293 else if mode is master-receiver: bus arbitration lost? (status.blost=1?) if yes, arbitration was lost: ? s1dat = dummy, write to release bus ? exit isr, sioe will switch to slave recv mode if no, aribitration was not lost, continue: is this interrupt from sending an address to slave, or is it from receiving a data byte from slave? if its from sending slave address, goto a: if its from receiving slave data, goto b: a: (interrupt is from master sending addr to slave) ack recvd from slave? (status.ack_resp=0?) if no, an ack was not received: ? s1con.sto = 1, set stop condition ? dummy = s1dat, read to release bus ? exit isr if yes, ack was received, then continue: ? dummy = s1dat, read to release bus does master want to receive just one data byte? if yes, do not allow master to ack on next interrupt: ? exit isr, now ready to recv one byte from slv if no, master can ack next byte from slv ? s1con.aa = 1, allow master to send ack ? exit isr, now ready to recv data from slave b: (interrupt is from master recving data from slv) ? recv_buf[buffer_index] = s1dat, read byte is this the last data byte to receive from slave? if yes, tell slave to stop transmitting: ? s1con.sto = 1, set stop bus condition ? exit isr, finished receiving data from slave if no, continue:
i 2 c interface upsd34xx 132/293 is this the next to last byte to receive from slave? if this is the next to last byte, do not allow master to ack on next interrupt. ? s1con.aa = 0, don?t let master return ack ? exit isr, now ready to recv last byte from slv if this is not next to last byte, let master send ack to slave ? exit isr, ready to recv more bytes from slave else if mode is slave-transmitter: is this intr from sioe detecting a stop on bus? if yes, a stop was detected: ? s1dat = dummy, write to release bus ? exit isr, master needs no more data bytes if no, a stop was not detected, continue: ack recvd from master? (status.ack_resp=0?) if no, an ack was not received: ? s1dat = dummy, write to release bus ? exit isr, master needs no more data bytes if yes, ack was received, then continue: ? s1dat = xmit_buf[buffer_index], transmit byte ? exit isr, transmit next byte on next interrupt else if mode is slave-receiver: is this intr from sioe detecting a stop on bus? if yes, a stop was detected: ? recv_buf[buffer_index] = s1dat, get last byte ? exit isr, master has sent last byte if no, a stop was not detected, continue: determine if this interrupt is from receiving an address or a data byte from a master. is (s1con.addr = 1 and s1con.aa =1)? if no, intr is from receiving data, goto c: if yes, intr is from an address, continue: ? slave_is_adressed = 1, local variable set true ? s1con.addr = 0, clear address match flag determine if r/w bit indicates transmit or receive.
upsd34xx i 2 c interface 133/293 does status.tx_mode = 1? if yes, master wants transmit mode ? exit isr, indicate master wants slv-xmit mode if no, master wants slave-recv mode ? dummy = s1dat, read to release bus ? exit isr, ready to recv data on next interrupt c: (interrupt is from slv receiving data from mastr) ? recv_buf[buffer_index] = s1dat, read byte ? exit isr, recv next byte on next interrupt
spi (synchronous peripheral interface) upsd34xx 134/293 24 spi (synchronous peripheral interface) upsd34xx devices support one serial spi interface in master mode only. this is a three- or four-wire synchronous communication channel, capable of full-duplex operation on 8-bit serial data transfers. the four spi bus signals are: spirxd pin p1.5 or p4.5 receives data from the slave spi device to the upsd34xx spitxd pin p1.6 or p4.6 transmits data from the upsd34xx to the slave spi device spiclk pin p1.4 or p4.4 clock is generated from the upsd34xx to the spi slave device spisel pin p1.7 or p4.7 selects the signal from the upsd34xx to an individual slave spi device this spi interface supports single-master/mu ltiple-slave connecti ons. multiple-master connections are not directly supported by the upsd34xx (no internal logic for collision detection). if more than one slave device is required, the spisel signal may be generated from upsd34xx gpio outputs (one for each slave) or from the pld outputs of the psd module. figure 44 illustrates three examples of spi de vice connections using the upsd34xx: single-master/single-slave with spisel single-master/single -slave without spisel single-master/multiple -slave without spisel figure 44. spi device connection examples spi bus spi bus spi bus spitxd spirxd upsd34xx spi master spi slave device spiclk spisel ai07853b mosi miso sclk single-master/single-slave, with spisel single-master/single-slave, without spisel single-master/multiple-slave, without spisel ss spi slave device mosi miso sclk ss spi slave device mosi miso sclk ss ss spitxd spirxd upsd34xx spi master spi slave device spiclk spitxd spirxd upsd34xx spi master spiclk gpio or pld gpio or pld mosi miso sclk
upsd34xx spi (synchronous peripheral interface) 135/293 24.1 spi bus features and communication flow the spiclk signal is a gated clock generated from the upsd34xx (master) and regulates the flow of data bits. the master may transmit at a variety of baud rates, and the spiclk signal will clock one period for each bit of transm itted data. data is sh ifted on one edge of spiclk and sampled on the opposite edge. the spitxd signal is generated by the master and received by the slave device. the spirxd signal is generated by the slave device and received by the master. there may be no more than one slave device transmitting data on spirxd at any given time in a multi- slave configuration. slave selection is acco mplished when a slave?s ?slave select? (ss) input is permanently grounded or asserted active-low by a master device. slave devices that are not selected do not interfere with spi activities. slave devices ignore spiclk and keep their miso output pins in high-impedance state when not selected. the spi specification allows a selection of clock polarity and clock phase with respect to data. the upsd34xx supports the choice of clock polarity, but it does not support the choice of clock phase (phase is fixed at what is typically known as cpha = 1). see figure 46 and figure 47 on page 137 for spi data and clock relationships. referring to these figures ( 46 and 47 ), when the phase mode is defined as such (fixed at cpha =1), in a new spi data frame, the master device begins driving the first data bit on spitxd at the very first edge of the first clock period of spiclk. the slave device will use this first clock edge as a transmission start indi cator, and therefore the slave?s slave select input signal may remain grounded in a single-master/single-slave configuration (which means the user does not have to use the spisel signal from upsd34xx in this case). the spi specification does not specify high-leve l protocol for data exchange, only low-level bit-serial transfers are defined. 24.2 full-duplex operation when an spi transfer occurs, 8 bits of data are shifted out on one pin while a different 8 bits of data are simultaneously shifted in on a sec ond pin. another way to view this transfer is that an 8-bit shift register in the master and another 8-bit shift register in the slave are connected as a circular 16-bit shift register. when a transfer occurs, this distributed shift register is shifted 8 bit positions; thus, the data in the master and slave devices are effectively exchanged (see figure 45 ). 24.3 bus-level activity figure 46 details an spi receive operation (with respect to bus master) and figure 47 details an spi transmit operation. also shown are internal flags available to firmware to manage data flow. these flags are accessed through a number of sfrs. note: the upsd34xx spi interface sfrs allow the choice of transmitting the most significant bit (msb) of a byte first, or the least significant bit (lsb) first. the same bit-order applies to data reception. figures 46 and 47 illustrate shifting the lsb first.
spi (synchronous peripheral interface) upsd34xx 136/293 figure 45. spi full-duplex data exchange figure 46. spi receive operation example spi bus slave device master device ai10485 ss spitxd spirxd baud rate generator 8-bit shift register 8-bit shift register spiclk mosi miso sclk bit7 spiclk (spo=0) spiclk (spo=1) spirxd bit0 bit1 bit7 bit0 bit1 bit7 1 frame risf roris busy spiintr spirdr full interrupt requested interrupt handler read data in spirdr spirdr full interrupt requested transmit end interrupt requested ai07855
upsd34xx spi (synchronous peripheral interface) 137/293 figure 47. spi transmit operation example 24.4 spi sfr registers six sfr registers control the spi interface: spicon0 ( ta bl e 6 3 ) for interface control spicon1 ( ta bl e 6 4 ) for interrupt control spitdr (sfr d4h, write only) holds byte to transmit spirdr (sfr d5h, read onl y) holds byte received spiclkd ( ta b l e 6 5 ) for clock divider spistat ( table 66 on page 142 ) holds interface status the spi interface functional block diagram ( figure 48 ) shows these six sfrs. both the transmit and receive data paths are double-buffered, meaning that continuous transmitting or receiving (back-to-back transfer) is possible by reading from spirdr or writing data to spitdr while shifting is taking place. there are a number of flags in the spistat register that indicate when it is full or empty to assist the 8032 mcu in data flow management. when enabled, these status flags will cause an interrupt to the mcu. bit0 spiclk (spo=0) spiclk (spo=1) spitxd bit1 bit7 bit0 bit1 bit7 1 frame tisf teisf busy spiintr spitdr empty interrupt requested interrupt handler write data in tdr spitdr empty interrupt requested transmit end interrupt requested spisel ai07854
spi (synchronous peripheral interface) upsd34xx 138/293 figure 48. spi interface, master mode only 24.5 spi configuration the spi interface is reset by the mcu reset, and firmware needs to initialize the sfrs spicon0, spicon1, and spiclkd to define several operation parameters. the spo bit in spicon0 determines the clock polarity. when spo is set to '0,' a data bit is transmitted on spitxd from one rising edge of spiclk to the next and is guaranteed to be valid during the falling edge of sp iclk. when spo is set to '1,' a data bit is transmitted on spitxd from one falling edge of spiclk to the next and is guaranteed to be valid during the rising edge of spiclk. the upsd34xx will sample received data on the appropriate edge of spiclk as determined by spo. the effect of the spo bit can be seen in figure 46 and figure 47 on page 137 . the flsb bit in spicon0 determines the bit order while transmitting and receiving the 8-bit data. when flsb is '0,' the 8-bit data is transferred in order from msb (first) to lsb (last). when flsb bit is set to '1,' the data is transferred in order from lsb (first) to msb (last). the clock signal generated on spiclk is derived from the internal periph_clk signal. periph_clk always operates at the frequency, f osc , and runs constantly except when stopped in mcu power down mo de. spiclk is a result of dividing periph_clk by a sum of different divisors selected by the value contained in the spiclkd register. the default value in spiclkd after a reset divides periph_clk by a factor of 4. the bits in spiclkd can be set to provide resulting divisor values in of sums of multiples of 4, such as 4, 8, 12, spitdr - transmit register spitxd / p1.6 or p4.6 timing and control (f osc ) intr to 8032 spirdr - receive register 8-bit shift register 8 8 8 8 spirxd / p1.5 or p4.5 spicon0, spicon1 - control registers 8 spistat - status register 8 8032 mcu data bus clock generate spisel / p1.7 or p4.7 spiclk / p1.4 or p4.4 clock divide 1 4 8 16 32 64 128 spiclkd - divide select 8 periph_clk ai10486
upsd34xx spi (synchronous peripheral interface) 139/293 16, 20, all the way up to 252. for example, if spiclkd contains 0x24, spiclk has the frequency of perih_clk divided by 36 decimal. the spiclk frequency must be set low enough to allow the mcu time to read received data bytes without loosing data. this is dependent upon many things, including the crystal frequency of the mcu and the efficiency of the spi firmware. 24.6 dynamic control at runtime, bits in registers spicon0, spicon1, and spistat are managed by firmware for dynamic control over the spi interface. the bits transmitter enable (te) and receiver enable (re) when set will allow transmitting and receiving resp ectively. if te is disabled, both transmitting and receiving are disabled be cause spiclk is driven to constant output logic ?0? (when spo = 0) or logic '1' (when spo = 1). when the ssel bit is set, the spisel pin will driv e to logic '0' (active) to select a connected slave device at the appropriate time before the first data bit of a byte is transmitted, and spisel will automatically return to logic '1' (inact ive) after transmitting the eight bi t of data, as shown in figure 47 on page 137 . spisel will continue to auto matically toggle this way for each byte data transmission while the ssel bi t is set by firmware. when the ssel bit is cleared, the spisel pin will drive to constant lo gic '1' and stay that way (after a transmission in progress completes). the interrupt enable bits (tei e, rorie,tie, and rie) when set, will allow an spi interrupt to be generated to the mcu upon the occurrence of the condition enabled by these bits. firmware must read the four corresponding flags in the spistat register to determine the specific cause of interrupt. these flags are automatically cleared when firmware reads the spistat register.
spi (synchronous peripheral interface) upsd34xx 140/293 table 63. spicon0: control register 0 (sfr d6h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? te re spien ssel flsb sbo ? bit symbol r/w definition 7 ? ? reserved 6terw transmitter enable 0 = transmitter is disabled 1 = transmitter is enabled 5rerw receiver enable 0 = receiver is disabled 1 = receiver is enabled 4 spien rw spi enable 0 = entire spi interface is disabled 1 = entire spi interface is enabled 3sselrw slave selection 0 = spisel output pin is constant logic '1' (slave device not selected) 1 = spisel output pin is logic '0' (slave device is selected) during data transfers 2flsbrw first lsb 0 = transfer the most significant bit (msb) first 1 = transfer the least significant bit (lsb) first 1 spo ? sampling polarity 0 = sample transfer data at the falling edge of clock (spiclk is '0' when idle) 1 = sample transfer data at the rising edge of clock (spiclk is '1' when idle) 0 ? ? reserved
upsd34xx spi (synchronous peripheral interface) 141/293 table 64. spicon1: spi interface control register 1 (sfr d7h, reset value 00h) table 65. spiclkd: spi prescaler (clock divider) register (sfr d2h, reset value 04h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ????teierorietierie bit symbol r/w definition 7-4 ? ? reserved 3teierw transmission end interrupt enable 0 = disable interrupt for transmission end 1 = enable interrupt for transmission end 2rorierw receive overrun interrupt enable 0 = disable interrupt for receive overrun 1 = enable interrupt for receive overrun 1tierw transmission interrupt enable 0 = disable interrupt for spitdr empty 1 = enable interrupt for spitdr empty 0rierw reception interrupt enable 0 = disable interrupt for spirdr full 1 = enable interrupt for spirdr full bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 div128 div64 div32 div16 div8 div4 ? ? bit symbol r/w definition 7div128rw 0 = no division 1 = divide f osc clock by 128 6div64rw 0 = no division 1 = divide f osc clock by 64 5div32rw 0 = no division 1 = divide f osc clock by 32 4div16rw 0 = no division 1 = divide f osc clock by 16 3div8rw 0 = no division 1 = divide f osc clock by 8 2div4rw 0 = no division 1 = divide f osc clock by 4 1-0 not used ?
spi (synchronous peripheral interface) upsd34xx 142/293 table 66. spistat: spi interface status register (sfr d3h, reset value 02h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? busy teisf rorisf tisf risf bit symbol r/w definition 7-5 ? ? reserved 4busyr spi busy 0 = transmit or receive is completed 1 = transmit or receive is in process 3 teisf r transmission end interrupt source flag 0 = automatically rese ts to '0' when firmware reads this register 1 = automatically sets to '1' when transmission end occurs 2 rorisf r receive overrun interrupt source flag 0 = automatically rese ts to '0' when firmware reads this register 1 = automatically sets to '1' when receive overrun occurs 1tisfr transfer interrupt source flag 0 = automatically rese ts to '0' when spitdr is full (just after the spitdr is written) 1 = automatically sets to '1' when spitdr is empty (just after byte loads from spitdr into spi shift register) 0risfr receive interrupt source flag 0 = automatically resets to '0' when spirdr is empty (after the spirdr is read) 1 = automatically sets to '1' when spirdr is full
upsd34xx usb interface 143/293 25 usb interface upsd34xx devices provide a full speed usb (uni versal serial bus) device interface. the serial interface engine (sie) provides the interface between the cpu and the usb (see figure 49 ). note: 1 for a list of known limitations of usb interface for upsd34xx devices, please refer to section 34: important notes on page 287 . 2 please make sure you have the latest 3400 usb firmware. the usb module supports the following features: usb 2.0 compliant to full-speed mode (12 mbps) 3.3v usb transceiver five endpoints including control endpoint 0 ? each endpoint includes two 64 byte fifos, one for in and one for out transactions ? endpoints 1 through 4 support interrupt and bulk transfers usb bus suspend detection and resume generation pll multiplier to generate the 48 mhz as required for usb support. interrupts for various usb bus conditions. performs nrzi encoding and decoding, bit stuffing, crc generation and checking, and serial/parallel data conversion double buffering (using fifo pairing) for efficient data transfer in bulk transfer busy bit-based fifo status monitoring fifos accessible via xdata space the analog front-end of the usb module is an on-chip usb transceiver. it is designed to allow voltage levels equal to v dd from the standard logic to interface with the physical layer of the usb. it is capable of receiving and transmitting serial data at full speed (12 mb/s). the sie is the digital-front-end of the usb bl ock. this module recovers the 12mhz clock, detects the usb sync word, and handles all low-level usb protocols and error checking. the bit-clock recovery circuit recovers the clock from the incoming usb data stream and is able to track jitter and frequency drift according to the usb specifications. the sie also translates the electrical usb si gnals into bytes or signals. when there is a usb device address match, the usb data is directed to an endpoint?s fifo for out transactions and read from an endpoint?s fifo for in transactions. control transfers are supported on endpoint0 and interrupt and bulk data transfers are supported on endpoints1 through 4. the device?s usb address and the enabling of the endpoints are programmable using the sie?s sfrs. important note: the usb sie requires a 48mhz clock to operate properly. a pll is included in the upsd34xx that must be programmed appropriately based on the input clock to provide a 48mhz clock to the sie (see section 14.2.2: usb_clk on page 60 to set up the pll).
usb interface upsd34xx 144/293 figure 49. usb module block diagram 25.1 basic usb concepts the universal serial bus (usb) is more complex than the standard serial port and requires familiarity with the specificatio n to fully understand how to use the usb peripheral in the upsd34xx. the usb specification is available on the internet at http://www.usb.org. some basic concepts will be presented in this sectio n but knowledge of the usb specification is required. in a usb system, there is only one master and the master is the host computer. the host controls all activity on the bus and devices respond to requests from the host. the only exception is when a device has been put into a low power suspend mode by the host. in this case, the device can signal a remote wakeup. outside of that exception, all activity is controlled and initiated by the host. the host-centric model versus a peer-to-peer model provides the best way to develop low cost per ipherals by keeping th e complex control logic on the host side. the upsd34xx is a peripheral (non-host) device. 25.1.1 communication flow the usb provides a means for communication between host (client) software and a function on a usb device. functions can have different requirements for the communication flow depending on the client software to the usb function interaction. with usb, the various communication flows are separated to provid e better bus utilization. for example, one communication flow is used for managing the device while another is for transferring data related to the operation of the device. some bus access is used for each communication flow with each flow terminated at an endpoint on a device. each endpoint has various aspects associated with the communication fl ow. a usb device looks like a collection of endpoints to the usb system. 8032 mcu usb sfrs usb transceiver serial interface engine pll clock ctrl and data ctrl and data ctrl ctrl x data d? d+ usb? usb+ s f r b u s ai10488 endpoint4 3 - 40mhz 48mhz endpoint0 endpoint4 endpoint0 in fifos (64 bytes each) out fifos (64 bytes each) setup command buffer (8 bytes) fifo interface logic
upsd34xx usb interface 145/293 25.1.2 endpoints each usb device contains a collection of independent endpoints, with an endpoint being the destination of a communication flow between client software and the device. by design, each usb device?s endpoints are given specific unique identifiers called endpoint numbers. in addition, each endpoint has an associated direction for the data flow, either in (from device to host) or out (from host to device). at the time a device is connected to the usb, it is assigned a unique address. the combinat ion of the device address, endpoint number, and direction allows each endpoint to be uniquely referenced. each endpoint has some associated characte ristics for the communication flow with the client software running on the host. those characteristics include: endpoint number; frequency and latency requirements; bandwidth requirements; maximum packet size capability; error handling requirements; data transfer direction; and transfer type. all usb devices are required to implement a default control method that uses both the input and output endpoints with endpoint zero. the usb system software uses this default control method to initialize and generically manipulate the logical device as the default control pipe. endpoint zero is always accessible and provides access to the device?s configuration and status information as well as some basic control access. additional (non-zero) endpoints provide the communication flow required for the functionality of the device. the non-zero endpoints are available for use only after the device is configured per the normal device configuration process (see chapter 9 of the usb specification, http://www.usb.org ). 25.1.3 packets usb transactions consist of data packets that contain special codes called packet ids (pids). a pid signifies the kind of packet that is being transmitted. while there are more types of pids in a usb system, the upsd34xx responds to the three types shown in ta bl e 6 7 table 67. types of packet ids figure 50 shows an example of packets sent during a usb transfer. the first packet is a token packet with an out pid. the out pid indicates that the host is going to send data to the addressed device?s endpoint. the addr field contains the a ddress of the device and the endp field contains the endpoint within th e addressed device. the crc5 is a cyclic redundancy check for error checking. pid type pid name to k e n i n , o u t, s e t u p data data0, data1 handshake ack, nak, stall
usb interface upsd34xx 146/293 the data packet contains a data1 or data0 pid. in a usb system, the host or device that is sending data is responsible for toggling the data pid between data0 and data1. the receiving device keeps track of the toggle bit and compares it with the data pid that is received. this provides a means for the receiving host or device to detect a corrupted handshake packet. the payload data is the data that the host is sending to the device and the crc16 is used for error checking. for an out transaction, the host sends the token and data packets. the receiving device sends a handshake packet to notify the host whether it was able to accept the packet or not. there are three handshake pids as follows: ack: this pid indicates that the devi ce received the da ta successfully. nak: this handshake indicates that the device was not able to receive the data (it is busy). a nak does not mean there was an error, since errors are indicated by a ?no handshake? packet. when the host receives a nak pid or does not receive a handshake packet at all, the host retries sending the data at a later time. stall: this handshake indicates that something is wrong. for example, the host has sent a device request that is not understood, the host is trying to access a resource that is not available, or someth ing is wrong with the device. figure 50. usb packets in a usb transfer example 25.1.4 data transfers with the host the host issues out tokens followed by data tokens to send data to a device. the device responds with an appropriate handshake packet (ack/nak), indicating whether it was able to receive the data. if the device does not receive the data packet ok (because there is some error), it does not respond with a handshake packet. in the case of a nak or no response, the host retries sending the data at a later time. usb devices are not able to send data to a host whenever they have it ready. when a device has data ready, it loads data into its endpoint buffer, making it ready for a transfer. the data will remain in the buffer until the host issues an in token to th at device?s endpoint, at which time the data will be sent. if th e host receives the data ok, it follows with an ack handshake (a host never naks). if the host did not receive the data ok, there is no handshake packet. in this case, the device should reload its endpoint buffer as appropriate and the host will retry again later to retrieve the data. token packet data packet handshake packet out addr endp crc5 crc16 ack data1 payload data 12 3 token packet data packet handshake packet out addr endp crc5 crc16 ack data0 payload data 45 6 ai10489
upsd34xx usb interface 147/293 25.2 types of transfers the usb specification defines four types of transfers, bulk, interrupt, isochronous, and control. note: the upsd34xx supports all types of transfers except isochronous. bulk transfers (see figure 51 ) bulk data is transferred in both directions an d is used with both in and out endpoints. packets may be 8, 16, 32, or 64 bytes in length. bulk transfers occur in bursts, and are scheduled by the host when there is available time on the bus. while there is no guaranteed delivery time for bulk transfers, the accuracy of the data is guaranteed due to automatic retries for erroneous data. bulk transfers are typically used for mass storage, printer, and scanner data. interrupt transfers (see figure 52 ) interrupt data is a lot like bulk data but travels only in one direction, from the device to the host, so only in endpoints are used. interrupt data holds packet sizes ranging from 1 to 64 bytes. interrupt endpoints have an associated polling interv al, meaning that the host sends in tokens at a periodic interval to the host on a regular basis. interrupt transfers are typically used for human interface devices such as keyboards, mice, and joysticks. figure 51. in and out bulk transfers figure 52. interrupt transfer token packet data packet handshake packet in addr endp crc5 crc16 ack data1 payload data token packet data packet handshake packet out addr endp crc5 crc16 ack data1 payload data ai10490 token packet data packet handshake packet in addr endp crc5 crc16 ack data1 payload data ai10491
usb interface upsd34xx 148/293 control transfers (see figure 53 ) control transfers are used to configure and send commands to a device. control transfers consist of two or three stages: ?setup this stage always consists of a data packet with eight bytes of usb control data. ? data stage (optional) if the control data is such that the host is requesting information from the device, the setup stage is followed by a data stage. in this case, the host sends an in token and the device responds with the requested data in the data packet. ? status stage this stage is essentially a handshake informing the device of a successfully completed control operation. 25.2.1 enumeration enumeration is the process that takes place wh en a device is first connected to the usb. during enumeration, the host requests information from the device about what it is, how many endpoints it has, the power requirements, bus bandwidth requirements, and what driver to load. once the enumeration process is complete, the device is available for use. the enumeration process consists of a series of six steps as follows: 1. when a device is first connected to the usb, its address is zero. upon detecting a new device connected to the usb, the host sends a get_descriptor request to address zero, endpoint0. 2. the device, upon receiving a get_descriptor request, sends data back to the host identifying what it is. 3. the host resets the device and then sends a set_address request. this is a unique address that identifies it from all other devices connected to the usb. this address remains in effect until the device is disconnected from the usb. 4. the host sends more get_descriptor requests to the device to gather more detailed information about it and then loads the specified driver. 5. the host will setup and enable the endpoints defined by the device. 6. the device is now configured and ready for use with the host communicating to the device using the assigned address and endpoints.
upsd34xx usb interface 149/293 figure 53. control transfer 25.3 endpoint fifos the upsd34xx?s usb module includes 5 endpoints and 10 fifos. each endpoint has two fifos with one for in and the other for out transactions. each fifo is 64 bytes long and is selectively made visible in a 64-byte xdat a segment for cpu access . for efficient data transfers, the fifos may be paired for double buffering. with double buffering, the cpu may operate on the contents in one buffer while the sie is transmitting or receiving data in the paired buffer. upsd34xx supported endpoints and fifos are shown in ta b l e 6 8 25.3.1 busy bit (bsy) operation each fifo has a busy bit ( bsy) that indicates when the usb sie has ownership of the fifo. when the sie has ownership of the fifo, it is either writing data to or reading data from the fifo. the sie writes data to the fifo when it is receiving an out packet and reads data from the fifo when it is sending data in response to an in packet. the cpu is only permitted to access the fi fo when it is not busy and accesses to it while busy are ignored. once the in fifo has been written with data by the cpu, the cpu updates the usize register with the number of bytes written to the fifo. the value written to the usize register tells the sie the number of bytes to send to the host in response to an in packet. once the usize register is written, the fifos busy bit is set and remains set until the data has been transmitted in response to an in packet. the busy bit for an out fifo is set as soon as the sie starts receiving an out packet from the host. once all the data has been received and written to the fifo, the sie clears the busy bit and writes the number of bytes received to the usize register. 25.3.2 busy bi t and interrupts when the fifo?s interrupt is enabled, a transition of the busy bit from a '1' to a '0' (when ownership of the fifo changes from the sie to the cpu) generates a usb interrupt with the corresponding flag set. for an interrupt on an in fifo, the cp u must fill the fifo with the next set of data to be sent and then update the usize register with the number of bytes to send. for an interrupt on an out fifo, the cpu reads the usize register to determine the number of bytes received and then reads that number of data bytes out of the fifo. token packet data packet handshake packet setup addr endp crc5 crc16 setup stage data stage (optional) status stage ack data0 payload data (8 bytes) token packet data packet handshake packet in addr endp crc5 crc16 ack data1 payload data token packet data packet handshake packet out addr endp crc5 crc16 ack data1 ai10492
usb interface upsd34xx 150/293 table 68. upsd34xx supported endpoints 25.3.3 fifo pairing the fifos on endpoints 1 through 4 may be used independently as shown in figure 54 as fifos with no pairing or they may be selectively paired to provide double buffering (see figure 55 on page 152 ). double buffering provides an efficient way to optimize data transfer rates with bulk transfers. double buffering allows the cpu to process a data packet for an endpoint while the sie is receiving or transmitting another packet of data on the same endpoint and direction. fifo pairing is contro lled by the usb pairing control register (see upair, table 71 on page 155 ). fifo pairing options are listed below: in fifo 1 and 2 out fifo 1 and 2 in fifo 3 and 4 out fifo 3 and 4 note: when the fifos are paired, the cpu must access the odd numbered fifo while the even numbered fifos are no longer available for use. also when they are paired, the active fifo is automatically toggled by the update of usize. non-pairing fifos example consider a case where the device needs to send 1024 bytes of data to the host. without fifo pairing (see figure 54 ), the cpu loads the in endpoint0 fifo with 64 bytes of data and waits until the host sends an in token to endpoint0, and the sie transfers the data to the host. once all 64 bytes have been transferred by the sie, the fifo becomes empty and the cpu starts writing the next 64 bytes of data to the fifo. while the cpu is writing the data to the fifo, the host is sending in tokens to endpoint0, requesting the next 64 bytes of data, but only gets naks while the fifo is being loaded. once the fifo has been loaded by the cpu, the sie starts sending the data to the host with the next in endpoint0 token. again, the cpu waits until the sie transfers the 64 bytes of data to the host. this is repeated until all 1024 bytes have been transferred. endpoint function max packet size (fifo size) supported directions 0 control 64 bytes out 0 control 64 bytes in 1 bulk/interrupt out 64 bytes out 1 bulk/interrupt in 64 bytes in 2 bulk/interrupt out 64 bytes out 2 bulk/interrupt in 64 bytes in 3 bulk/interrupt out 64 bytes out 3 bulk/interrupt in 64 bytes in 4 bulk/interrupt out 64 bytes out 4 bulk/interrupt in 64 bytes in
upsd34xx usb interface 151/293 figure 54. fifos with no pairing pairing fifos example now assume that in endpoint1 and endpoint2 fifos are paired for double buffering and the same 1024 bytes of data are to be transferred to the host. as in the non- pairing example, the cpu loads the in endpoint0 fifo with 64 bytes of data. instead of having to wait for the sie to transfer the 64 bytes of data to the host, the cpu can write another 64 bytes of data to in endpoint0 fifo. while the cpu is writing the second packet of 64 bytes of data into the fifo, the sie is sending the first packet of 64 bytes of data to the host. after the cpu has written the second packet of 64 bytes to the fifo, it waits a shorter amount of time for the sie to complete sending the first packet of data since they were working concurrently. as soon as the first packet is sent by the sie, the second packet is immediately available to be sent by the sie since the fifo was already loaded by the mcu. also, after the first packet is sent by the sie, the alternate fifo is available for the mcu to load the third packet of 64 bytes of data. with double buffering, the mcu is able to always have a fifo loaded and ready with data to be sent by the sie when the host sends an in token maximizing the data transfer rate. 8032 mcu usb sfrs serial interface engine ctrl x data s f r b u s ai10493 endpoint4 in fifo endpoint3 in fifo endpoint2 in fifo endpoint1 in fifo endpoint0 in fifo endpoint0 out fifo endpoint1 out fifo endpoint2 out fifo endpoint3 out fifo endpoint4 out fifo fifo interface logic endpoint4 endpoint3 endpoint2 endpoint1 endpoint0 endpoint0 endpoint1 endpoint2 endpoint3 endpoint4
usb interface upsd34xx 152/293 figure 55. fifo pairing example (1/2 in paired and 3/4 out paired) 25.3.4 reading and writing fifos there are a total of ten 64-byte fifos. each of the five endpoints has two fifos, one in fifo for in transactions and one out fifo for out transactions. the fifos are accessible by the cpu through a 64-byte segment in the xdata space when the visible bit is set (see table 80 on page 163 ). if the visible bit is not set, the fifos are not accessible by the cpu but are still accessible by the sie. the base address of the 64-byte segment is specified by the usb base address high register (see table 85 on page 168 ) and the usb base address low register (see table 86 on page 168 ). when the visible bit is set, the fifo that is accessible in the 64-byte xdata space segment is the fifo selected by the usel register. the usel register contains two fields used for selecting the accessible fifo. the ep field determines the endpoint selected and the dir bit selects the in or out fifo associated with the endpoint. 25.3.5 accessing fifo control registers, ucon, and usize each of the 10 endpoint fifos has an associated usb endpoint control register (ucon, 0f1h) and a usb fifo valid size register (usize, 0f2h). the usb endpoint select register (usel) is not only used to select t he endpoint fifo that is accessible in the xdata space, but also selects the associated endpoint?s ucon and usize registers that are accessible at sfr addresses 0f1h and 0f2h. 25.3.6 accessing the setup command buffer setup packets are sent from the host to a device?s endpoint0 and consist of 8 bytes of command data. when the sie receives a setup packet from the host, it stores the 8 bytes of data in the command buffer. the command buffer is accessed via the indexed usb setup 8032 mcu usb sfrs serial interface engine ctrl x data s f r b u s ai10494 endpoint4 in fifo endpoint3 in fifo endpoint2 in fifo p a i r e d p a i r e d endpoint1 in fifo endpoint0 in fifo endpoint0 out fifo endpoint1 out fifo endpoint2 out fifo fifo interface logic endpoint4 endpoint3 endpoint2 (not available) endpoint2 (not available) endpoint1 endpoint0 endpoint4 endpoint3 endpoint1 endpoint0 endpoint0 endpoint1 endpoint2 endpoint3 endpoint0 endpoint1 endpoint2 endpoint3 endpoint4 (not available) endpoint4 (not available) endpoint3 out fifo p a i r e d p a i r e d endpoint4 out fifo
upsd34xx usb interface 153/293 command value register (uscv). the usb setup command index register (usci) is used to select the byte from the command buffer that is read when accessing the uscv register. 25.4 usb registers the usb module is controlled via registers m apped into the sfr space. the usb sfrs consist of the following: uaddr: usb device address upair: usb fifo pairing control uie0~3: usb interrupt enable uif0~3: usb interrupt flags uctl: usb control usta: usb status usel: usb endpoint and direction select ucon: usb selected fi fo control register usize: usb selected fifo size register ubase: usb base address register usci: usb setup command index uscv: usb setup command value the memory map for the usb sfrs, the individual bit names, and the reset values are shown in ta b l e 6 9 . table 69. upsd34xx usb sfr register map sfr addr (hex) sfr name bit name and reset value (hex) comment 76543210 e2 uaddr ? usbaddr[6:0] 00 usb address e3 upair ? ? ? ? pr3ou t pr1out pr3in pr1in 00 usb pairing control e4 uie0 ? ? ? ? rstie suspndie eopie resumie 00 usb global interrupt enable e5 uie1 ? ? ? in4ie in3ie in2ie in1ie in0ie 00 usb in fifo interrupt enable e6 uie2 ? ? ? out4ie out3ie o ut2ie out1ie out0ie 00 usb out fifo interrupt enable e7 uie3 ? ? ? nak4ie nak3ie nak2ie nak1ie nak0ie 00 usb in fifo nak int. enable e8 uif0 glf inf outf nakf rstf suspndf eopf resumf 00 usb global interrupt flag e9 uif1 ? ? ? in4f in3f in2f in1f in0f 00 usb in fifo interrupt flag ea uif2 ? ? ? out4f out3f out2f out1f out0f 00 usb out fifo interrupt flag
usb interface upsd34xx 154/293 note: bits marked with a ??? are reserved. 25.4.1 usb device address register initially when a device is connec ted to the usb, it responds to the host on address 0. using the set_address request, the host assigns a unique address to the device. the firmware writes this address to the usb device address register (see ta bl e 7 0 ), and subsequently the sie only responds to transactions on that assigned address. this assigned address is in effect until the device or an upstream hub is disconnected from the us b, the host issues a usb reset, or the host shuts down. the address register is cleared with a hardware reset. when a usb reset is detected, th e address register should be cleared. 25.4.2 endpoint fifo pairing endpoint fifos can be paired for double buffering to provide an efficient method for bulk data transfers. with double buffering enabled, the mcu can operate on one data packet while another is being transferred over usb. when two fifos are paired, the active fifo is automatically toggled by the update of usize. the mcu must only use the odd numbered endpoint fifo when paired in order to access the active fifo. for example, if endpoints 3 and 4 out fifos are paired, the active fifo is accessed via endpoint 3?s out fifo (see ta b l e 7 1 ). eb uif3 ? ? ? nak4f nak3f nak2f nak1f nak0f 00 usb in fifo nak int. flag ec uctl ? ? ? ? ? usben visible wakeup 00 usb control ed usta ? ? ? ? rcvt setup in out 00 usb status ee reserved ef usel dir ? ? ? ? ep[2:0] 00 usb endpoint select f1 ucon ? ? ? ? enable stall toggl e bsy 08 usb endpoint control f2 usize ? size[6:0] 00 usb fifo valid size f3 ubaseh baseaddr[15:8] 00 usb base address high f4 ubasel baseaddr [7:6] 00000000 usb base address low f5 usci ? ? ? ? ? usci[2:0] 00 usb setup command index f6 uscv uscv[7:0] 00 usb setup command value sfr addr (hex) sfr name bit name and reset value (hex) comment 76543210
upsd34xx usb interface 155/293 table 70. usb device address regist er (uaddr 0e2h, reset value 00h) table 71. pairing control register (upair 0e3h, reset value 00h) 25.4.3 usb interrupts there are many usb related events that generate an interrupt. the events that generate an interrupt are selectively enabled through the use of the usb interrupt enable registers. all usb interrupts are serviced through a single interrupt vector (see section 13: interrupt system on page 52 for the address of the interrupt vector). when a usb interrupt occurs, firmware must check the usb interrupt flag registers to determine the source of the interrupt, clear that interrupt flag and process the interrupt before returning to the interrupted code. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? usbaddr[6:0] bit symbol r/w definition 7 ? ? reserved 6:0 usbaddr r/w usb address of the device. these bits are clear ed with a hardware reset. when a usb reset is detected, the addre ss register should be cleared. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? pr3out pr1out pr3in pr1in bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3pr3outr/w setting this bit enables double buffering of the out fifos for endpoints 3 and 4. access to the double buffered fifos is through endpoint3?s out fifo. 2pr1outr/w setting this bit enables double buffering of the out fifos for endpoints 1 and 2. access to the double buffered fifos is through endpoint1?s out fifo. 1pr3inr/w setting this bit enables double buffering of the in fifos for endpoints 3 and 4. access to the double buffered fifos is through endpoint3?s in fifo. 0pr1inr/w setting this bit enables double buffering of the in fifos for endpoints 1 and 2. access to the double buffered fifos is through endpoint1?s in fifo.
usb interface upsd34xx 156/293 the usb interrupt priority can be set to low or high. for the best usb response time and to maximize data transfer times, the usb interrupt should be set to the highest priority (see the section 13: interrupt system for the details on setting the interrupt priority). usb reset interrupt the host signals a bus reset by driving both d+ and d? low for at least 10ms. when the upsd34xx?s sie detects a reset on the usb, it generates the rst interrupt request. a usb reset does not reset the cpu nor the usb sie, nor does it disable the usb sie. the interrupt service routine should disable/enable the usb sie to reset a portion of the state machine and initialize the usb sie registers per the application requirements. usb suspend interrupt if the upsd34xx?s sie detects 3ms of no activity on the bus, it generates the suspend interrupt request. it also causes the clock to the sie to shut down to conserve power. usb eop (end of packet) interrupt every packet sent on the usb includes a signal, called eop, to indicate the end of the packet. when an eop is detected, the sie generates an eop interrupt. usb resume interrupt when usb activity is detected and the sie is in the suspend state, a resume interrupt is generated. the usb resume interrupt service routine should clear the suspendf bit in the uif0 register if it is set in order to turn the usb sie clock on. usb global interrupt enable register (uie0) there are four usb events that are considered to be global in nature, meaning they are not specific to an endpoint, but apply to the usb bus in general. the four global usb events include reset, suspend, eop, and resume. each event can be enabled to generate an interrupt using the uie0 register shown in ta bl e 7 2 table 72. usb global interrupt enable register (uie0 0e4h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ????rstie suspend ie eopie resumie bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 rstie r/w enable the usb reset interrupt 2 suspend ie r/w enable the usb suspend interrupt 1 eopie r/w enable the usb eop interrupt 0 resumie r/w enable the usb resume interrupt
upsd34xx usb interface 157/293 usb in fifo interrupt enable register (uie1) when an endpoint?s in fifo has been successfully sent to the host with an in transaction, the fifo becomes empty. the uie1 register is used to enable each endpoint?s in fifo interrupt ( ta bl e 7 3 ). usb out fifo interrupt enable register (uie1) when an endpoint?s out fifo has been filled by an out transaction from the host, the fifo becomes full. the uie2 register is used to enable each endpoint?s out fifo interrupt ( ta bl e 7 4 ). table 73. usb in fifo interrupt enable register (uie1 0e5h, reset value 00h) table 74. usb out fifo interrupt enable register (uie2 0e6h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? in4ie in3ie in2ie in1ie in0ie bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 in4ie r/w enable endpoint 4 in fifo interrupt 3 in3ie r/w enable endpoint 3 in fifo interrupt 2 in2ie r/w enable endpoint 2 in fifo interrupt 1 in1ie r/w enable endpoint 1 in fifo interrupt 0 in0ie r/w enable endpoint 0 in fifo interrupt bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? out4ie out3ie out2ie out1ie out0ie bit symbol r/w definition 7??reserved 6??reserved 5??reserved 4 out4ie r/w enable endpoint 4 out fifo interrupt 3 out3ie r/w enable endpoint 3 out fifo interrupt 2 out2ie r/w enable endpoint 2 out fifo interrupt 1 out1ie r/w enable endpoint 1 out fifo interrupt 0 out0ie r/w enable endpoint 0 out fifo interrupt
usb interface upsd34xx 158/293 usb in fifo nak interrupt enable register (uie3) when an endpoint?s in fifo is empty and an in transaction to that endpoint has been received, the sie sends a nak handshake token since there is no data ready for it to send. the uie3 register (see ta b l e 7 5 ) is used to enable each endpoint?s in fifo nak interrupt. table 75. usb in fifo nak interrupt enable register (uie3 0e7h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? nak4ie nak3ie nak2ie nak1ie nak0ie bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 nak4ie r/w enable endpoint 4 in fifo nak interrupt 3 nak3ie r/w enable endpoint 3 in fifo nak interrupt 2 nak2ie r/w enable endpoint 2 in fifo nak interrupt 1 nak1ie r/w enable endpoint 1 in fifo nak interrupt 0 nak0ie r/w enable endpoint 0 in fifo nak interrupt
upsd34xx usb interface 159/293 usb global interrupt flag register (uif0) there are many different events that generate a usb interrupt requiring a number of registers to indicate the cause of the interrupt. to more efficiently identify the cause of the interrupt, the usb global interrupt flag register (see ta bl e 7 6 ) indicates the type of interrupt that occurred. once the type of interrupt is identified, the associated interrupt flag register may be read to determine the exact cause of the interrupt. table 76. usb global interrupt flag register (uif0 0e8h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 glf inf outf nakf rstf suspendf eopf resumf bit symbol r/w definition 7glfr global interrupt flag logical or of the rstf, suspendf, eopf, and resumf interrupt flags 6infr in fifo interrupt flag logical or of the in4f, in3f, in2f, in1f, and in0f interrupt flags 5outfr out fifo interrupt flag logical or of the out4f, out3f, out2f, out1f, and out0f interrupt flags 4 nakf r nak fifo interrupt flag logical or of the nak4f, nak3f, nak2f, nak1f, and nak0f interrupt flags 3rstfr/w usb reset flag this bit is set when a usb reset is detected on the d+ and d- lines. note: a usb reset does not reset the mcu nor the usb module. firmware should disable/enable the usb sie using the usen bit in the uctl register and initialize all usb related registers as appropriate. 2 suspendf r/w usb suspend mode flag this bit is set when the sie de tects 3ms of no activity on the bus and the clock to the sie is also shut down to conserve power. clearing this bit turns the sie clock on. 1 eopf r/w end of packet flag this bit is set when a valid end of packet sequence is detected on the d+ and d? line. 0 resumef r/w resume flag this bit is set when usb bus activity is detected while the suspndf bit is set. when a resume is detected, the suspendf bit must be cleared (if set) to turn the sie clock on.
usb interface upsd34xx 160/293 usb in fifo interrupt flag (uif1) the usb in fifo interrupt flag register (see ta bl e 7 7 ) contains flags that indicate when an in endpoint fifo that was full becomes empty. once set, firmware must clear the flag by writing a '0' to the appropriate bit. when fifos are paired, only the odd numbered fifo interrupt flags are active. table 77. usb in fifo interrupt flag (uif1 0e9h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? in4f in3f in2f in1f in0f bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4in4fr/w endpoint 4 in fifo interrupt flag this bit is set when the fifo stat us changes from full to empty. 3in3fr/w endpoint 3 in fifo interrupt flag this bit is set when the fifo stat us changes from full to empty. 2in2fr/w endpoint 2 in fifo interrupt flag this bit is set when the fifo stat us changes from full to empty. 1in1fr/w endpoint 1 in fifo interrupt flag this bit is set when the fifo stat us changes from full to empty. 0in0fr/w endpoint 0 in fifo interrupt flag this bit is set when the fifo stat us changes from full to empty.
upsd34xx usb interface 161/293 usb out fifo interrupt flag (uif2) the usb out fifo interrupt flag register (see ta bl e 7 8 ) contains flags that indicate when an out endpoint fifo that was empty becomes full. once set, firmware must clear the flag by writing a '0' to the appropriate bit. when fifos are paired, only the odd numbered fifo interrupt flags are active. table 78. usb out fifo interrupt flag (uif2 0eah, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? out4f out3f out2f out1f out0f bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4out4fr/w endpoint 4 out fifo interrupt flag this bit is set when the fifo status changes from empty to full. 3out3fr/w endpoint 3 out fifo interrupt flag this bit is set when the fifo status changes from empty to full. 2out2fr/w endpoint 2 out fifo interrupt flag this bit is set when the fifo status changes from empty to full. 1out1fr/w endpoint 1 out fifo interrupt flag this bit is set when the fifo status changes from empty to full. 0out0fr/w endpoint 0 out fifo interrupt flag this bit is set when the fifo status changes from empty to full.
usb interface upsd34xx 162/293 usb in fifo nak interrupt flag (uif3) the usb in fifo nak interrupt flag register (see ta bl e 7 9 ) contains flags that indicate when an in endpoint fifo is not ready. the endpoint fifo is not ready when data has not been loaded into its fifo and the usize register has not been written to (writing to the usize register puts the fifo in a ?ready? to send data state). until the fifo is ready, the sie will continue to nak a ll in requests to the respective endpoint. once set, firmware must clear the flag by writing a '0' to the appropriate bit. when fifos are paired, only the odd numbered fifo interrupt flags are active. table 79. usb in fifo nak interrupt flag (uif3 0ebh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? nak4f nak3f nak2f nak1f nak0f bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 nak4f r/w endpoint 4 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 3 nak3f r/w endpoint 3 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 2 nak2f r/w endpoint 2 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 1 nak1f r/w endpoint 1 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready. 0 nak0f r/w endpoint 0 in fifo nak interrupt flag this bit is set when the sie responded to an in request with a nak since the fifo was not ready.
upsd34xx usb interface 163/293 usb control register (uctl) the usb control register (see ta b l e 8 0 ) is used to enable the sie, make the endpoint fifos visible in the xdata space and for generating a remote wakeup signal. upon a reset, the usb module is disabled and must be enabled by the cpu for communication with the host over the usb. table 80. usb control register (uctl 0ech, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? ? usben visible wakeup bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 ? ? reserved 2 usben r/w usb enable when this bit is set, the usb function is enabled and the sie responds to tokens from the host. when this bit is clear, the usb function is disabled and does not respond to any tokens from the host. note: a usb reset does not clear this bit. disabling and enabling the sie using this bit re sets part of the usb sie state machine and some of the bits in the usta and ucon registers. 1visibler/w usb fifo visible when this bit is set, the se lected usb fifo is accessible (visible) in the xdata space. 0 wakeup r/w remote wakeup enable this bit forces a resume or ?k? state on the usb data lines to initiate a remote wake-up. the cpu is responsible for controlling the timing of the forced resume that must be between 10ms and 15ms. setting this bit will not cause the resumf bit to be set.
usb interface upsd34xx 164/293 usb endpoint0 status (usta) the usb endpoint0 status register (see ta bl e 8 1 ) provides the status for events that occur on the usb that are directed to endpoint0. table 81. usb endpoint0 status (usta 0edh, reset value 00h) important note: disabling and enabling the usb sie using the usben bit in the uctl register clears the rcvt, in, and out bits in this register. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? rcvt setup in out bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3rcvtr received data toggle bit this bit indicates the toggle bit of the received data packet: 0 = data0, and 1 = data1 2setupr/w setup token detect bit this bit is set when endpoint0 receives a setup token. this bit is not cleared when endpoint0 receives an in or out token following the setup token that set this bit. this bit is cleared by software or a reset. 1inr in token detect bit this bit is set when endpoint0 receives an in token. this bit is cleared when endpoint0 receives a setup or out token. 0outr out token detect bit this bit is set when endpoint0 receives an out token. this bit is cleared when endpoint0 receives a setup or in token.
upsd34xx usb interface 165/293 usb endpoint select register (usel) endpoints share the same xdata space for fifos as well as the same sfr addresses for control and fifo valid size registers. the usb endpoint select register (see ta bl e 8 2 ) is used to select the desired direction and endpoint that is accessed when reading or writing to the fifo xdata address space. this register is also used to select the direction and endpoint when accessing the usb endpoint control register. table 82. usb endpoint select register (usel 0efh, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 dir ? ? ? ? ep[2] ep[1] ep[0] bit symbol r/w definition 7dirr/w fifo?s direction select bit: 0: in fifo select 1: out fifo select 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 ? ? reserved 2:0 ep r/w endpoint selects bits: 0: endpoint0 1: endpoint1 2: endpoint2 3: endpoint3 4: endpoint4
usb interface upsd34xx 166/293 usb endpoint contro l register (ucon) the endpoint selected by the usb endpoint select register (see table 82 on page 165 ) determines the direction and fifo (in or out) that is controlled by the usb endpoint control register (see ta bl e 8 3 ). the usb endpoint control register is used to control the selected endpoint and provides some status about that endpoint. table 83. usb endpoint control register (ucon 0f1h, reset value 08h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? enable stall toggle bsy bit symbol r/w definition 7 ? ? reserved 6 ? ? reserved 5 ? ? reserved 4 ? ? reserved 3 enable r/w selected fifo enable bit. note: all fifos for each endpoint is enabled after a reset. 2stallr/w stall control bit when this bit is set, the endpoint returns a stall handshake whenever it receives an in or out token. 1 toggle r data toggle bit ? endpoint in case the state of this bit determines the type of data packet (0=data0 or 1=data1) that will be sent during th e next in transaction. this bit is managed by the usb sie. it is onl y toggled when an ack is properly received during the in transaction. in some cases it may be necessary for firmware to clear this bit. in this case, see the important notes section at the end of this data sheet. ? endpoint out case the state of this bit indicates the type of data packet pid that the usb sie expects to receive with the next out transaction (0=data0, 1=data1). if the data toggle for the next out transaction received is not as expected, the usb sie assu mes the host is retransmitting the last packet. in this case, an ack is sent but no interrupt is generated since the original transmission of the packet was ok. this bit is managed by the usb sie. it is only toggled when an out packet is properly received. in some cases it may be necessary for firmware to clear this bit. in this case, see the important notes section at the end of this data sheet. important notes: 1. disabling and enablin g the usb sie using the usben bit the uctl register clears the toggle bit for both directions of all endpoints. 2. revision a silicon: see the import ant notes section at the end of the data sheet that explains the workaround for clearing this data toggle bit. 3. revision b silicon: disabling and enabling the selected fifo using the enable bit in this register clears the data toggle bit for the selected endpoint's fifo.
upsd34xx usb interface 167/293 usb fifo valid size (usize) the endpoint selected by the usb endpoint select register (see table 82 on page 165 ) determines the direction and fifo that is controlled by the usb fifo valid size (see ta bl e 8 4 ). the usb fifo valid size register indicates the number of bytes loaded into the in fifo that the sie is to send in a data packet for an endpoint in case and indicates the number of bytes received for an endpoint out case. table 84. usb fifo valid size (usize 0f2h, reset value 00h) 0bsyr/w fifo busy status ? endpoint in case once the fifo has been loaded and armed (usize written with the number of bytes to send), the bsy bit is set and remains set until the sie has transmitted the data in the fifo. the cpu should only access the fifo when bsy = 0. ? endpoint out case while the sie is receivi ng data and storing it in the fifo (bsy = 1), it should not be accessed by the cpu. once the out transaction is complete (bsy=0), the cpu may read the contents of the fifo. the bsy bit will remain clear ed until another out trans action is received. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? size[6:0] bit symbol r/w definition 7 ? ? reserved 6:0 size r/w ? endpoint in case the cpu writes the usize register with the number of bytes it loaded into the in endpoint fifo for transmission with the next in transaction. once the usize register has been written, the fifo becomes ready for transmission. ? endpoint out case the cpu reads the usize regist er to determine how many bytes were received in the data packet during the last out transaction. this tells the cpu how many valid bytes to read from the fifo. note: since the fifos are 64 bytes in length, the maximum value for size is 64 (40h). bit symbol r/w definition
usb interface upsd34xx 168/293 usb fifo base addres s high and low register s (ubaseh and ubasel) all 10 endpoint fifos share the same 64-byte address range. the 16-bit base address for the fifos is specified using the usb base address registers (see ta bl e 8 5 and ta bl e 8 6 ). the usb endpoint select register (see table 82 on page 165 ) selects the direction and the endpoint for the fifo that is accessed when addressing the 64- bytes of xdata space starting with the base address specified in the base address registers. the base address is a 64-byte segment where the lower 6 bits of the base register are hardwired to '0.' important note: the usb fifo base address must be set to an open 64-byte segment in the xdata space. care should be taken to ensure that there is no overlap of addresses between the usb fifos and the flash memory, sram, csiop registers, and anything else accessed in the xdata space. while the logic in the psd module handles overlap of flash memory, sram, and the csiop registers with a fixed priority (see section 28.1: psd module functional description on page 185 ), this is not the case with the usb fifos. unpredictable re sults as well as potential damage to the device may occur if there is an overlap of addresses. table 85. usb fifo base address high register (ubaseh 0f3h, reset value 00h) table 86. usb fifo base address low register (ubasel 0f4h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 baseaddr[15:8] bit symbol r/w definition 7:0 baseaddr [15:8] r/w the upper 8 bits of the 16-bit base address for usb fifos to be mapped in xdata space bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 baseaddr[7:6] 0 0 0000 bit symbol r/w definition 7:6 baseaddr [7:6] r/w bits 7 and 6 of the 16-bit base address for the usb fifos to be mapped in xdata space 5:0 baseaddr [5:0] r hardwired '0'
upsd34xx usb interface 169/293 usb setup command index and value registers (usci and uscv) when a setup/data packet is received over the usb, the 8 bytes of data received are stored in a command buffer. the usb setup command index register (see ta b l e 8 7 ) determines which one of the eight bytes in the buffer is read using the usb setup command value register (see ta bl e 8 8 ). table 87. usb setup command index register (usci 0f5h, reset value 00h) table 88. usb setup command value register (uscv 0f6h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? ? ? usci[2:0] bit symbol r/w definition 7:3 ? ? reserved 2:0 usci[2:0] r/w index to access one of the 8 bytes of usb setup command data received with the last setup transaction bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 uscv[7:0] bit symbol r/w definition 7:0 uscv r/w the nth byte of the 8 bytes of usb setup command data received with the last setup trans action. the nth byte that is read from this register is specified by the index value in the usci register.
usb interface upsd34xx 170/293 25.5 typical connection to usb connecting the upsd34xx to the usb is simple and straightforward. figure 56 shows a typical self-powered example requiring only three resistors and a usb power detection circuit. the usb power detection circuit detect s when the device has been connected to the usb. when v bus is detected, it switches 3.3v to the pull-up resistor on the d+ line. per the usb specification, the pull-up resistor on d+ is required to signal to the upstream usb port when a full speed device has been connected to the bus. the resistors in series in the d+ and d? lines are recommended per the usb specification to reduce transients on the data lines. figure 56. typical self powered example usb power detection block 22 ? v bus v cc d? d+ gnd usb? usb+ gnd v cc v dd v cc v dd 22 ? usb upsd34xx 1.5k ? +3.3v ai10495
upsd34xx analog-to-digital convertor (adc) 171/293 26 analog-to-digital convertor (adc) the adc unit in the upsd34xx is a sar type adc with an sar register, an auto-zero comparator and three internal dacs. the unit has 8 input channels with 10-bit resolution. the a/d converter has its own av ref input (80-pin package only), which specifies the voltage reference for the a/d operations. the analog to digital converter (a/d) allows conversion of an analog input to a corresponding 10-bit digital value. the a/d module has eight analog inputs (p1.0 through p1.7) to an 8x1 multiplexor. one adc channel is selected by the bits in the configuration register. the converter generates a 10-bits result via successive approximation. the analog supply voltage is connected to the av ref input, which powers the resistance ladder in the a/d module. the a/d module has 3 registers, the control register acon, the a/d result register adat0, and the second a/d result register adat1. the adat0 register stores bits 0.. 7 of the converter output, bits 8.. 9 are stored in bits 0..1 of the adat1 register. the acon register controls the operation of the a/d converter module. three of the bits in the acon register select the analog channel inputs, and the remaining bits control the converter operation. adc channel pin input is enabled by setting the corresponding bit in the p1sfs0 and p1sfs1 registers to '1' and the channel select bits in the acon register. the adc reference clock (adcclk) is generated from f osc divided by the divider in the adcps register. the adc operates within a range of 2 to 16mhz, with typical adcclk frequency at 8mhz. the conversion time is 4s typical at 8mhz. the processing of conversion starts when the start bit adst is set to '1.' after one cycle, it is cleared by hardware. the adc is monotonic with no missing codes. measurement is by continuous conversion of the analog input. the adat register contains the results of the a/d conversion. when conversion is complete, the result is loaded into the adat. the a/d conversion status bit adsf is set to '1.' the block diagram of the a/d module is shown in figure 57 . the a/d status bit adsf is set automatically when a/d conversion is completed and cleared when a/d conversion is in process. in addition, the adc unit sets the interrupt flag in the acon register after a conversion is complete (if ainten is set to '1'). the adc in terrupts the cpu when the enable bit ainten is set. 26.1 port 1 adc channel selects the p1sfs0 and p1sfs1 registers control the selection of the port 1 pin functions. when the p1sfs0 bit is '0,' the pin functions as a gpio. when bits are set to '1,' the pins are configured as alternate functions. a new p1sfs1 register selects which of the alternate functions is enabled. the adc channel is enabled when the bit in p1sfs1 is set to '1.' note: in the 52-pin package, there is no individual av ref pin because av ref is combined with av cc pin.
analog-to-digital c onvertor (adc) upsd34xx 172/293 figure 57. 10-bit adc analog mux select adc out - 10 bits adat 0 reg acon reg control 10-bit sar adc adat1 reg adc0 adc1 adc2 adc3 adc4 adc5 adc6 adc7 av ref p1.0 p1.1 p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 av ref ai07856
upsd34xx analog-to-digital convertor (adc) 173/293 table 89. acon register (sfr 97h, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 aintf ainten aden ads2 ads1 ads0 adst adsf bit symbol function 7aintf adc interrupt flag. this bit must be cleared with software. 0 = no interrupt request 1 = the aintf flag is set when adsf goes from '0' to '1.' interrupts cpu when both aintf and aint en are set to '1.' 6ainten adc interrupt enable 0 = adc interrupt is disabled 1 = adc interrupt is enabled 5aden adc enable bit 0 = adc shut off and consumes no operating current 1 = enable adc. after adc is enabled, 16ms of calibration is needed before adst bit is set. 4.. 2 ads2.. 0 analog channel select 000 select channel 0 (p1.0) 001 select channel 0 (p1.1) 010 select channel 0 (p1.2) 011 select channel 0 (p1.3) 101 select channel 0 (p1.5) 110 select channel 0 (p1.6) 111 select channel 0 (p1.7) 1adst adc start bit 0 = force to zero 1 = start adc, then after one cycl e, the bit is cleared to '0.' 0adsf adc status bit 0 = adc conversion is not completed 1 = adc conversion is completed. the bit can also be cleared with software.
analog-to-digital c onvertor (adc) upsd34xx 174/293 table 90. adcps register details (sfr 94h, reset value 00h) table 91. adat0 register (sfr 95h, reset value 00h) table 92. adat1 register (sfr 96h, reset value 00h) bit symbol function 7:4 ? reserved 3 adcce adc conversion reference clock enable 0 = adc reference clock is disabled (default) 1 = adc reference clock is enabled 2:0 adcps[2:0] adc reference clock prescaler only three prescaler values are allowed: adcps[2:0] = 0, for f osc frequency 16mhz or less . resulting adc clock is f osc . adcps[2:0] = 1, for f osc frequency 32mhz or less . resulting adc clock is f osc /2. adcps[2:0] = 2, for f osc frequency 32mhz > 40mhz. resulting adc clock is f osc /4. bit symbol function 7:0 ? store adc output, bit 7 - 0 bit symbol function 7:2 ? reserved 1.. 0 ? store adc output, bit 9, 8
upsd34xx programmable counter array (pca) with pwm 175/293 27 programmable counter array (pca) with pwm there are two programmable counter array blocks (pca0 and pca1) in the upsd34xx. a pca block consists of a 16-bit up-counter, which is shared by three tcm (timer counter module). a tcm can be programmed to perform one of the following four functions: 1. capture mode: capture counter va lues by external input signals 2. timer mode 3. toggle output mode 4. pwm mode: fixed frequency (8-bit or 16-bit), programmable frequency (8-bit only) 27.1 pca block the 16-bit up-counter in the pca block is a free-running counter (except in pwm mode with programmable frequency). the counter has a choice of clock input: from an external pin, timer 0 overflow, or pca clock. a pca block has 3 timer counter modules (tcm) which share the 16-bit counter output. the tcm can be configured to capture or compare counter value, generate a toggling output, or pwm functions. except for the pwm function, the other tcm functions can generate an interrupt when an event occurs. every tcm is connected to a port pin in port 4; the tcm pin can be configured as an event input, a pwms, a toggle output, or as external clock input. the pins are general i/o pins when not assigned to the tcm. the tcm operation is configured by control registers and capture/compare registers. table 93 on page 176 lists the sfr registers in the pca blocks. figure 58. pca0 block diagram timer0 overflow p4.3/eci pcach0 8-bit pcacl0 8-bit clksel1 idle mode (from cpu) ovf0 int eovfi tcm0 tcm1 tcm2 pwm freq compare p4.0/cex0 p4.1/cex1 p4.2/cex2 16-bit up timer/counter clksel0 pcaidle pca0clk clear counter en_pca en_all ai07857
programmable counter array (pca) with pwm upsd34xx 176/293 table 93. pca0 and pca1 registers 27.2 pca clock selection the clock input to the 16-bit up counter in the pca block is user-programmable. the three clock sources are: pca prescaler clock (pca0clk, pca1clk) timer 0 overflow external clock, pin p4.3 or p4.7 the clock source is selected in the configuration register pcacon. the prescaler output clock pcaclk is the f osc divided by the divisor which is specified in the ccon2 or ccon3 register. when external clock is selected, the maximum clock frequency should not exceed f osc /4. sfr address register name rw register function pca0 pca1 pca0 pca1 a2 ba pcacl0 pcacl1 rw the low 8 bits of pca 16-bit counter. a3 bb pcach0 pcach1 rw the high 8 bits of pca 16-bit counter. a4 bc pcacon0 pcacon1 rw control register ? enable pca, timer overflow flag , pca idle mode, and select clock source. a5 a5 pcasta n/a rw status register, interrupt status flags ? common for both pca block 0 and 1. a9, aa, ab bd, be, bf tcmmode0 tcmmode1 tcmmode2 tcmmode3 tcmmode4 tcmmode5 rw tcm mode ? capture, compare, and toggle enable interrupts ? pwm mode select. ac ad c1 c2 capcoml0 capcomh0 capcoml3 capcomh3 rw capture/compare registers of tcm0 af b1 c3 c4 capcoml1 capcomh1 capcoml4 capcomh4 rw capture/compare registers of tcm1 b2 b3 c5 c6 capcoml2 capcomh2 capcoml5 capcomh5 rw capture/compare registers of tcm2 b4 c7 pwmf0 pwmf1 rw the 8-bit register to program the pwm frequency. this register is used for programmable, 8-bit pwm mode only. fb fc ccon2 ccon3 rw specify the pre-scaler value of pca0 or pca1 clock input
upsd34xx programmable counter array (pca) with pwm 177/293 table 94. ccon2 register bit definition (sfr 0fbh, reset value 10h) table 95. ccon3 register bit definition (sfr 0fch, reset value 10h) 27.3 operation of tcm modes each of the tcm in a pca block supports four modes of operation. however, an exception is when the tcm is configured in pwm mode with programmable frequency. in this mode, all tcm in a pca block must be configured in the same mode or left to be not used. 27.4 capture mode the capcom registers in the tcm are loaded with the counter values when an external pin input changes state. the user can configure the counter value to be loaded by positive edge, negative edge or any transition of the input signal. at loading, the tcm can generate an interrupt if it is enabled. 27.5 timer mode the tcm modules can be configured as software timers by enable the comparator. the user writes a value to the capcom registers, which is then compared with the 16-bit counter. if there is a match, an interrupt can be generated to cpu. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? pca0ce pca0ps3 pca0ps2 pca0ps1 pca0ps0 bit symbol r/w definition 4pca0cer/w pca0 clock enable 0 = pca0clk is disabled 1 = pca0clk is enabled (default) 3:0 pca0ps [3:0] r/w pca0 prescaler f pca0clk = f osc / (2 ^ pca0ps[3:0]) divisor range: 1, 2, 4, 8, 16... 16384, 32768 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? ? ? pca1ce pca1ps3 pca1ps2 pca1ps1 pca1ps0 bit symbol r/w definition 4pca1cer/w pca1 clock enable 0 = pca1clk is disabled 1 = pca1clk is enabled (default) 3:0 pca1ps [3:0] r/w pca1 prescaler f pca1clk = f osc / (2 ^ pca1ps[3:0]) divisor range: 1, 2, 4, 8, 16... 16384, 32768
programmable counter array (pca) with pwm upsd34xx 178/293 27.6 toggle mode in this mode, the user writes a value to the tcm's capcom registers and enables the comparator. when there is a match with the counter output, the output of the tcm pin toggles. this mode is a simple extension of the timer mode. 27.7 pwm mode - (x8), fixed frequency in this mode, one or all the tcm's can be configured to have a fixed frequency pwm output on the port pins. the pwm frequency depends on when the low byte of the counter overflows (modulo 256). the duty cycle of each tcm module can be specified in the capcomhn register. when the pca_counter_l value is equal to or greater than the value in capcomln, the pwm output is switched to a high state. when the pca_counter_l register overflows, the content in capcomhn is loaded to capcomln and a new pwm pulse starts. figure 59. timer mode note: m = 0: n = 0, 1, or 2 m = 1: n = 3, 4, or 5 match_timer intr 0 0 0 tcmmoden enable 8 8 match pcasta capcomln pcaclm pcachm 16-bit comparator capcomhn intfn 0 0 16-bit up timer/counter 8 8 eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 reset write to capcomhn write to capcomln 1 0 en_flag d c ai07858
upsd34xx programmable counter array (pca) with pwm 179/293 figure 60. pwm mode - (x8), fixed frequency note: m = 0: n = 0, 1, or 2 m = 1: n = 3, 4, or 5 27.8 pwm mode - (x8), programmable frequency in this mode, the pwm frequency is not determined by the overflow of the low byte of the counter. instead, the frequency is determined by the pwmfm register. the user can load a value in the pwmfm register, which is then compared to the low byte of the counter. if there is a match, the counter is cleared and the load registers (pwmfm, capcomhn) are re-loaded for the next pwm pulse. there is only one pwmfm register which serves all 3 tcm in a pca block. if one of the tcm modules is operating in this mode, the other modules in the pca must be configured to the same mode or left not to be used. the duty cycle of the pwm can be specified in the capcomhn register as in the pwm with fixed frequency mode. different tcm modules can have their own duty cycle. note: the value in the frequency register (pwmfm) must be larger than the duty cycle register (capcom). capcomhn overflow enable 8 pcaclm 8 capcomln 8-bit comparatorn cexn match s r q q set clr 0 0 tcmmoden 0 0 0 eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 ai07859
programmable counter array (pca) with pwm upsd34xx 180/293 figure 61. pwm mode - (x8) programmable frequency note: m = 0: n = 0, 1, or 2 m = 1: n = 3, 4, or 5 27.9 pwm mode - fixed frequency, 16-bit the operation of the 16-bit pwm is the same as the 8-bit pwm with fixed frequency. in this mode, one or all the tcm can be configured to have a fixed frequency pwm output on the port pins. the pwm frequency is depending on the clock input frequency to the 16-bit counter. the duty cycle of each tcm module can be specified in the capcomhn and capcomln registers. when the 16-bit pca_counter is equal or greater than the values in registers capcomhn and capcomln, the pwm output is switched to a high state. when the pca_counter overflows, cexn is asserted low. clr pcachm pwm freq compare pwmfm = pcaclm pcaclm capcomhn cexn enable enable 8 8 pwmfm 8-bit comparatorm 8-bit comparatorn capcomln match s r q q set clr 8 0 0 tcmmoden 0 0 0 eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 ai07860
upsd34xx programmable counter array (pca) with pwm 181/293 27.10 pwm mode - fixed frequency, 10-bit the 10-bit pwm logic requires that all 3 tcms in pca0 or pca1 operate in the same 10-bit pwm mode. the 10-bit pwm operates in a similar manner as the 16-bit pwm, except the pcachm and pcaclm counters are reconfigured as 10-bit counters. the capcomhn and capcomln registers become 10-bit registers. pwm duty cycle of each tcm module can be specified in the 10-bit capcomhn and capcomln registers. when the 10-bit pca counte r is equal or greater than the values in the 10-bit registers capcomhn and capcomln, th e pwm output switches to a high state. when the 10-bit pca counter overflows, the pwm pin is switched to a logic low and starts the next pwm pulse. the most-significant 6 bits in the pcachm counter and capcomh register are ?don?t cares? and have no effect on the pwm generation. 27.11 writing to capture/compare registers when writing a 16-bit value to the pca capture/compare registers, the low byte should always be written first. writing to capcomln clears the e_comp bit to '0'; writing to capcomhn sets e_comp to '1' the largest duty cycle is 100% (capcomhn capcomln = 0x0000), and the smallest duty cycle is 0.0015% (capcomhn capcomln = 0xffff). a 0% duty cycle may be generated by clearing the e_comp bit to ?0?. 27.12 control register bit definition each pca has its own pca_confign, and each module within the pca block has its own tcm_mode register which defines the operation of that module (see table 96 on page 182 through table 97 on page 182 ). there is one pca_status register that covers both pca0 and pca1 (see table 98 on page 183 ).
programmable counter array (pca) with pwm upsd34xx 182/293 table 96. pca0 control register pcacon0 (sfr 0a4h, reset value 00h) table 97. pca1 control register pcacon1 (sfr 0bch, reset value 00h) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 en-all en_pca eovfi pca idle ? ? clk_sel[1:0] bit symbol function 7en-all 0 = no impact on tcm modules 1 = enable both pca counters simultaneously (override the en_pca bits) this bit is to start the two 16-bit counters in the pca. for customers who want 5 pwm, for example, this bi t can start all of the pwm outputs. 6en_pca 0 = pca counter is disabled 1 = pca counter is enabled en_pca counter run control bit. se t with software to turn the pca counter on. must be cleared with software to turn the pca counter off. 5 eovfi 1 = enable counter overflow inte rrupt if overflow flag (ovf) is set 4pcaidle 0 = pca operates when cpu is in idle mode 1 = pca stops running when cpu is in idle mode 3?reserved 210b_pwm 0 = select 16-bit pwm 1 = select 10-bit pwm 1-0 clk_sel [1:0] 00 select prescaler cl ock as counter clock 01 select timer 0 overflow 10 select external clock pin (p4.3 for pca0) (max clock rate = f osc /4) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ? en_pca eovfi pcaidle ? ? clk_sel[1:0] bit symbol function 6en_pca 0 = pca counter is disabled 1 = pca counter is enabled en_pca counter run control bit. se t with software to turn the pca counter on. must be cleared with software to turn the pca counter off. 5 eovfi 1 = enable counter overflow inte rrupt if overflow flag (ovf) is set 4pcaidle 0 = pca operates when cpu is in idle mode 1 = pca stops running when cpu is in idle mode 3?reserved 210b_pwm 0 = select 16-bit pwm 1 = select 10-bit pwm 1-0 clk_sel [1:0] 00 select prescaler cl ock as counter clock 01 select timer 0 overflow 10 select external clock pin (p4.7 for pca1) (max clock rate = f osc /4)
upsd34xx programmable counter array (pca) with pwm 183/293 table 98. pca status register pcasta (sfr 0a5h, reset value 00h) 27.13 tcm interrupts there are 8 tcm interrupts: 6 match or capture interrupts and two counter overflow interrupts. the 8 interrupts are ?ored? as one pca interrupt to the cpu. by the nature of pca application, it is unlikely that many of the interrupts occur simultaneously. if they do, the cpu has to read the interrupt flags and determine which one to serve. the software has to clear the interrupt flag in the status register after serving the interrupt. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ovf1 intf5 intf4 intf3 ovf0 intf2 intf1 intf0 bit symbol function 7ofv1 pca1 counter overflow flag set by hardware when the counter rolls over. ovf1 flags an interrupt if bit eovfi in pcacon1 is set. ovf1 may be set with either hardware or software but can only be cleared with software. 6intf5 tcm5 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 5intf4 tcm4 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 4intf3 tcm3 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 3ovf0 pca0 counter overflow flag set by hardware when the counter rolls over. ovf0 flags an interrupt if bit eovfi in pcacon0 is set. ovf1 may be set with either hardware or software but can only be cleared with software. 2intf2 tcm2 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 1intf1 tcm1 interrupt flag set by hardware when a match or capture event occurs. must be clear with software. 0intf0 tcm0 interrupt flag set by hardware when a match or capture event occurs. must be clear with software.
programmable counter array (pca) with pwm upsd34xx 184/293 table 99. tcmmode0 - tcmmode5 (6 registers, reset value 00h) table 100. tcmmode register configurations note: 1 10-bit pwm mode requires the 10b_pwm bit in the pcacon register set to '1.' bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 eintf e_comp cap_pe cap_ne match toggle pwm[1:0] bit symbol function 7eintf 1 - enable the interrupt flags (intf) in the status register to generate an interrupt. 6 e_comp 1 - enable the comparator when set 5 cap_pe 1 - enable capture mode, a positive edge on the cexn pin. 4 cap_ne 1 - enable capture mode, a negative edge on the cexn pin. 3 match 1 - a match from the comparator sets the intf bits in the status register. 2 toggle 1 - a match on the comparator results in a toggling output on cexn pin. 1-0 pwm[1:0] 01 enable pwm mode (x8), fixed frequency. enable the cexn pin as a pwm output. 10 enable pwm mode (x8) with programmable frequency. enable the cexn pin as a pwm output. 11 enable pwm mode (x10 or x16), fixed frequency. enable the cexn pin as a pwm output. eintf e_comp cap_pe cap_ne match toggle pwm1 pwm0 tcm function 00 0 00 000 no operation (reset value) 01 0 00 001 8-bit pwm, fixed frequency 01 0 00 010 8-bit pwm, programmable frequency 01 0 00 011 10-bit or 16-bit pmw, fixed frequency (1) x 1 0 0 1 1 0 0 16-bit toggle x1 0 0 1 000 16-bit software timer xx 0 1 0 0 00 16-bit capture, negative trigger xx 1 0 0 0 00 16-bit capture, positive trigger xx 1 1 0 0 00 16-bit capture, transition trigger
upsd34xx psd module 185/293 28 psd module the psd module is stacked with the mcu module to form the upsd34xx, see section 3: hardware description on page 17 . details of the psd module are shown in figure 62 . the two separate modules interface with each other at the 8032 address, data, and control interface blocks in figure 62 . figure 62. psd module block diagram 28.1 psd module functional description major functional blocks are shown in figure 62 on page 185 . the next sections describe each major block. pd1 pd2 port d pa 0 pa 1 pa 2 pa 3 pa 4 pa 5 pa 6 pa 7 pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 port b general pld 20 input macrocells 16 output macrocells a b a b a b a b a b a b a b a b b c b c b c b c b c b c b c b c security lock pld input bus pin feedback node feedback psd module: upsd34xx decode pld and-or array fs0-7 aaaaaaaa bbbbbbbb c c c c to pld input bus pc0 pc1 pc2 pc3 pc4 pc5 pc6 pc7 port c jtag-isp to all areas of psd module addr, data, control bus linked to 8032 mcu runtime control, 256 regs gpio, vm, page power mngmt csiop pld csboot0-3 external chip- selects main flash memory up to 8 segments up to 256 kbytes total fs0 fs7 2nd flash memory up to 4 segments up to 32 kbytes total csboot0 csboot3 data low address latch data high address latch a0-a7 a8-a15 8032 mux addr/data ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 8032 mux addr/data ad8 ad9 ad10 ad11 ad12 ad13 ad14 ad15 8032 control psen ale rd wr rst 8032 mcu module port a (80-pin only) to jtag debug on mcu gpio pld gpio gpio gpio 8 pin inputs mcu read or write mcu read pld out pld out pld out pld out pld out jtag cntl 8 pin inputs 4 pin inputs mcu read or write rs0 up to 32 kbytes sram page reg jtag omc allo- cator and-or array 69 inputs 69 inputs ai10454b pld input bus
psd module upsd34xx 186/293 28.1.1 8032 address/data/control interface these signals attach directly to the mcu modu le to implement a 16-b it multiplexed 8051- style bus between the two stacked die. the mcu instruction prefetch and branch cache logic resides on the mcu module, leaving a modified 8051-style memory interface on the psd module. the active-low reset signal originating from the mcu module goes to the psd module reset input (rst ). this reset signal can then be routed as an external output from the upsd34xx to the system pc board, if needed, through any one of the pld output pins as active-high or active-low logic by specifying logic equations in psdsoft express. the 8032 address and data busses are routed throughout the psd module as shown in figure 62 connecting many elements on the psd module to the 8032 mcu. the 8032 bus is not only connected to the memories, but also to the general pld, making it possible for the 8032 to directly read and write individual logic macrocells inside the general pld. 28.1.2 dual flash memories and iap upsd34xx devices contain two independent fl ash memory arrays. this means that the 8032 can read instructions from one flash memory array while erasing or writing the other flash memory array. concurrent operation like this enables robust remote updates of firmware, also known as in-application programming (iap). iap can occur using any upsd34xx interface (e.g., uart, i2c, spi). concurrent memory operation also enables the designer to emulate eeprom memory within either of the two flash memory arrays for small data sets that have frequent updates. the 8032 can erase flash memories by individu al sectors or it can erase an entire flash memory array at one time. each sector in either flash memory may be individually write protected, blocking any writes from the 8032 (good for boot and start-up code protection). the flash memories automatically go to standby between 8032 read or write accesses to conserve power. minimum erase cycles is 10 0k and minimum data retention is 15 years. flash memory, as well as the entire psd module may be programmed with the jtag in- system programming (isp) interface with no 8032 involvement, good for manufacturing and lab development. 28.1.3 main flash memory the main flash memory is divided into equal sized sectors that are individually selectable by the decode pld output signals, named fsx, one signal for each main flash memory sector. each flash sector can be located at any address within 8032 program address space (accessed with psen ) or data address space, also known as 8032 xdata space (accessed with rd or wr ), as defined with the software development tool, psdsoft express. the user only has to specify an add ress range for each segment and specify if main flash memory will reside in 8032 data or program address space, and then psen , rd , or wr are automatically activated for the specified range. 8032 firmware is easily programmed into main flash memory using psdsoft express or other software tools. see table 101 on page 187 for main flash sector sizes on the various upsd34xx devices. 28.1.4 secondary flash memory the smaller secondary flash memory is also divided into equal sized sectors that are individually selectable by the decode pld signals, named csbootx, one signal for each secondary flash memory sector. each sector can be located at any address within 8032
upsd34xx psd module 187/293 program address space (accessed with psen ) or xdata space (accessed with rd or wr ) as defined with psdsoft express. the user only has to specify an address range for each segment, and specify if seco ndary flash memory will reside in 8032 data or program address space, and then psen , rd , or wr are automatically activated for the specified range. 8032 firmware is easily programmed into secondary flash memory using psdsoft express and others. see table 101 on page 187 for secondary flash sector sizes. 28.1.5 sram the sram is selected by a single signal, named rs0, from the decode pld. sram may be located at any address within 8032 xdata space (accessed with rd or wr ). these choices are specified using psdsoft express, where the user specifies an sram address range. see table 101 on page 187 for sram sizes. the sram may optionally be backed up by an external battery (or other dc source) to make its contents non-volatile (see section 28.5.62: sram standby mode (battery backup) on page 250 ). table 101. upsd34xx memory configuration 28.1.6 runtime control registers, csiop a block of 256 bytes is decoded inside the psd module for module control and status (see table 106 on page 199 ). the base address of these 256 locations is referred to in this data sheet as csiop (chip select i/o port), and is selected by the decode pld output signal, csiop. the csiop registers are always viewed by the 8032 as xdata, and are accessed with rd and wr signals. the address range of csiop is specified using psdsoft express where the user only has to specify an address range of 256 bytes, and then the rd or wr signals are automatically activated for the spec ified range. individual registers within this block are accessed with an offset from the specified csiop base address. 39 registers are used out of the 256 locations to control the output state of i/o pins, to read i/o pins, to set the memory page, to control 8032 program and data address space, to control power management, to read/write macrocells inside the general pld, and other functions during runtime. unused locations within csiop are reserved and should not be accessed. 28.1.7 memory page register 8032 mcu architecture has an inherent size limit of 64k bytes in either program address space or xdata space. some upsd34xx devices have much more memory that 64k, so special logic such as this page register is needed to access the extra memory. this 8-bit page register ( figure 63 ) can be loaded and read by the 8032 at runtime as one of the csiop registers. page register outputs feed directly into both plds creating extended address device main flash memory secondary flash memory sram total flash size (bytes) individual sector size (bytes) number of sectors (sector select signal) total flash size (bytes) individual sector size (bytes) number of sectors (sector select signal) sram size (bytes) upsd3422 64k 16k 4 (fs0-3) 32k 8k 4 (csboot0-3) 4k upsd3433 128k 16k 8 (fs0-7) 32k 8k 4 (csboot0-3) 8k upsd3434 256k 32k 8 (fs0-7) 32k 8k 4 (csboot0-3) 8k upsd3454 256k 32k 8 (fs0-7) 32k 8k 4 (csboot0-3) 32k
psd module upsd34xx 188/293 signals used to ?page? memory beyond the 64k byte limit (program space or xdata). most 8051 compilers directly support memory paging, also known as memory banking. if memory paging is not needed, or if not all eight page register bits are needed for memory paging, the remaining bits may be used in the general pld for general logic. page register outputs are cleared to logic ?0? at reset and power-up. 28.1.8 programmable logic (plds) the upsd34xx contains two plds ( figure 74 on page 215 ) that may optionally run in turbo or non-turbo mode. plds operate faster (less propagation delay) while in turbo mode but consume more power than in non-turbo mode. non-turbo mode allows the plds to go to standby automatically when no pld inputs are changing to conserve power. the logic configuration (from equations) of both plds is stored with non-volatile flash technology and the logic is active upon power-up. plds may not be programmed by the 8032, pld programming only occurs through the jtag interface. figure 63. memory page register 28.1.9 pld #1, decode pld (dpld) this programmable logic implements memory mapping and is used to select one of the individual main flash memory segments, one of individual secondary flash memory segments, the sram, or the group of csiop registers when the 8032 presents an address to dpld inputs (see figure 75 on page 217 ). the dpld can also optionally drive external chip select signals on port d pins. the dpld also optionally produces two select signals (psel0 and psel1) used to enable a special data bus repeater function on port a, referred to as peripheral i/o mode. there are 69 dpld input signals which include: 8032 address and control signals, page register outputs, psd module port pin inputs, and gpld logic feedback. 28.1.10 pld #2, general pld (gpld) this programmable logic is used to create both combinatorial and sequential general purpose logic (see figure 76 on page 218 ). the gpld contains 16 output macrocells (omcs) and 20 input macrocells (imcs). output macrocell registers are unique in that they have direct connection to the 8032 data bus allowing them to be loaded and read directly by the 8032 at runtime through omc registers in csiop. this direct access is good for making 8032 data bus load or read via csiop + offset e0h d0 d7 d6 d5 d4 d3 d2 d1 q0 q7 q6 q5 q4 q3 q2 q1 dpld and gpld page register chip- selects and general logic rst (psd module reset) rst pgr0-7 ai09172
upsd34xx psd module 189/293 small peripheral devices (shifters, counters, state machines, etc.) that are accessed directly by the 8032 with little overhead. there are 69 gpld inputs which include: 8032 address and control signals, page register outputs, psd module port pin inputs, and gpld feedback. 28.1.11 omcs there are two banks of eight omcs inside the gpld, mcellab, and mcellbc, totalling 16 omcs all together. each in dividual omc is a base logic element consisting of a flip-flop and some and-or logic ( figure 77 on page 220 ). the general structure of the gpld with omcs is similar in nature to a 22v10 pld device with the familiar sum-of-products (and- or) construct. true and compliment versions of 69 input signals are available to the inputs of a large and-or array. and-or array outputs feed into an or gate within each omc, creating up to 10 product-terms for each omc. logic output of the or gate can be passed on as combinatorial logic or combined with a flip-flop within in each omc to realize sequential logic. omc outputs can be used as a buried nodes driving internal feedback to the and-or array, or omc outputs can be routed to external pins on ports a, b, or c through the omc allocator. 28.1.12 omc allocator the omc allocator ( figure 78 on page 221 ) will route eight of the omcs from mcellab to pins on either port a or port b, and will rout e eight of the omcs from mcellbc to pins on either port b or port c, based on what is specified in psdsoft express. 28.1.13 imcs inputs from pins on ports a, b, and c are routed to imcs for conditioning (clocking or latching) as they enter the chip, which is good for sampling and debouncing inputs. alternatively, imcs can pass port input signals directly to pld inputs without clocking or latching ( figure 79 on page 224 ). the 8032 may read the imcs asynchronously at any time through imc registers in csiop. note: the jtag signals tdo, tdi, tck, and tms on port c do not route through imcs, but go directly to jtag logic. 28.1.14 i/o ports for 80-pin upsd34xx devices, the psd module has 22 individually configurable i/o pins distributed over four ports (these i/o are in addition to i/o on mcu module). for 52-pin upsd34xx devices, the psd module has 13 indi vidually configurable i/o pins distributed over three ports. see figure 85 on page 237 for i/o port pin availability on these two packages. i/o port pins on the psd module (ports a, b, c, and d) are completely separate from the port pins on the mcu module (ports 1, 3, and 4). they even have different electrical characteristics. i/o port pins on the psd module are accessed by csiop registers, or they are controlled by pld equations. conversely, i/o port pins on the mcu module are controlled by the 8032 sfr registers.
psd module upsd34xx 190/293 table 102. general i/o pins on psd module note: four pins on port c are dedicated to jtag, leaving four pins for general i/o. each i/o pin on the psd module can be individually configured for different functions on a pin-by-pin basis ( figure 80 on page 226 ). following are the available functions on psd module i/o pins. mcu i/o: 8032 controls the output state of each port pin or it reads input state of each port pin, by accessing csiop registers at run-ti me. the direction (in or out) of each pin is also controlled by csiop registers at run-time. pld i/o: psdsoft express logic equations and pin configuration selections determine if pins are connected to omc outputs or imc inputs. this is a static and non-volatile configuration. port pins connected to pld outputs can no longer be driven by the 8032 using mcu i/o output mode. latched mcu address output: port a or port b can output de-multiplexed 8032 address signals a0 - a7 on a pin-by-pin bas is as specified in csiop registers at run- time. in addition, port b can also be configured to output de-multiplexed a8-a15 in psdsoft express. data bus repeater: port a can bi-directionally buffer the 8032 data bus (de- multiplexed) for a specified address range in psdsoft express. this is referred to as peripheral i/o mode in this document. open drain outputs: some port pins can function as open-drain as specified in csiop registers at run-time. pins on port d can be used for external chip-select outputs originating from the dpld, without consuming omc resources within the gpld. 28.1.15 jtag port in-system programming (isp) can be performed through the jtag signals on port c. this serial interface allows programming of the entire psd module device or subsections of the psd module (for example, only flash memory but not the plds) without the participation of the 8032. a blank upsd34xx device soldered to a circuit board can be completely programmed in 10 to 25 seconds. the four basic jtag signals on port c; tms, tck, tdi, and tdo form the ieee-1149.1 interface. th e psd module does not implement the ieee- 1149.1 boundary scan functions, but uses the jtag interface for isp an 8032 debug. the psd module can reside in a sta ndard jtag chain with other jt ag devices and it will remain in bypass mode when ot her devices perform jtag functions. isp programming time can be reduced as much as 30% by using two optional jtag signals on port c, tstat and terr , in addition to tms, tck, tdi and tdo, and this is referred to as ?6-pin jtag?. the flashlink jtag programming cable is available from stmicroelectronics and psdsoft express software is available at no charge from www.st.com/psm. more jtag isp information maybe found in section 28.6.1: jtag isp and jtag debug on page 251 . the mcu module is also included in the jtag chain within the upsd34xx device for 8032 debugging and emulation. while debugging, the psd module is in bypass mode. conversely, during isp, the m cu module is in bypass mode. pkg port a port b port c port d total 52-pin084113 80-pin884222
upsd34xx psd module 191/293 28.1.16 power management the psd module has bits in csiop registers that are configured at run-time by the 8032 to reduce power consumption of the gpld. the turbo bit in the pmmr0 register can be set to logic ?1? and both plds will go to non-turbo mode , meaning it will latch it s outputs and go to sleep until the next transition on its inputs. there is a slight penalty in pld performance (longer propagation delay), but significant power savings are realized. going to non-turbo mode may require an additional wait state in the 8032 sfr, buscon, because memory decode signals are also delayed. the default st ate of the turbo bit is logic '0,' meaning by default, the gpld is in fast turbo mode until the user turns off turbo mode. additionally, bits in csiop registers pmmr0 and pmmr2 can be set by the 8032 to selectively block signals from entering both plds which further reduces power consumption. there is also an automatic power down counter that detects lack of 8032 activity and reduces power consumption on the psd module to its lowest level (see section 28.1.16: power management on page 191 ). 28.1.17 security and nvm sector protection a programmable security bit in the psd module protects its contents from unauthorized viewing and copying. the security bit is specified in psdsoft express and programmed into the upsd34xx with jtag. once set, the securi ty bit will block access of jtag programming equipment to the psd module flash memory and pld configuration, and also blocks jtag debugging access to the mcu module. the only way to defeat the security bit is to erase the entire psd module using jtag (the erase command is the only jtag command allowed after the security bit has been set), after which the device is blank and may be used again. additionally and independently, the contents of each individual flash memory sector can be write protected (sector protection) by configur ation with psdsoft express. this is typically used to protect 8032 boot code from being corrupted by inadvertent writes to flash memory from the 8032. status of sector protection bits may be read (but not written) using two registers in csiop space. 28.2 memory mapping there many different ways to place (or map) the address range of psd module memory and i/o depending on system requ irements. the dpld provides complete mapping flexibility. figure 64 shows one possible system memory map. in this example, 128k bytes of main flash memory for a upsd3433 device is in 8032 program address space, and 32k bytes of secondary flash memory, the sram, and csiop registers are all in 8032 xdata space. in figure 64 , the nomenclature fs0..fs7 are designators for the individual sectors of main flash memory, 16k bytes each. csboot0..csboot3 are designators for the individual secondary flash memory segments, 8k bytes each. rs0 is the designator for sram, and csiop designates the psd modu le control register set. the designer may easily specify memory mappin g in a point-and-click software environment using psdsoft express, creating a non-volatile configuration when the dpld is programmed using jtag.
psd module upsd34xx 192/293 28.2.1 8032 program address space in the example of figure 64 , six sectors of main flash memory (fs2.. fs7) are paged across three memory pages in the upper half of program address space, and the remaining two sectors of main flash memory (fs0, fs1) reside in the lower half of program address space, and these two sectors are independent of paging (they reside in ?common? program address space). this paged memory example is quite common and supported by many 8051 software compilers. 28.2.2 8032 data address space (xdata) four sectors of secondary flash memory reside in the upper half of 8032 xdata space in the example of figure 64 . sram and csiop registers are in the lower half of xdata space. the 8032 sfr registers and local sram inside the 8032 mcu module do not reside in xdata space, so it is ok to place psd module sram or csiop registers at an address that overlaps the address of internal 8032 mcu module sram and registers. figure 64. typical system memory map 28.2.3 specifying the memo ry map with psdsoft express the memory map example shown in figure 64 on page 192 is implemented using psdsoft express in a point-and-clic k environment. psdsoft expre ss will automatically generate hardware definition language (hdl) statements of the abel language for the dpld, such as those shown in ta b l e 1 0 3 . specifying these equations using psdsoft express is very simple. for example, figure 65 , page 84 shows how to specify the chip-select equation for the 16k byte flash memory segment, fs4. notice fs4 is on memory page 1. this specification process is repeated for all other flash memory segments, the sram, the csiop register block, and any external chip select signals that may be needed. 0000h 8000h a000h c000h e000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot0 8kb csboot1 8kb csboot2 8kb csboot3 8kb page x fs0 , 16kb common memory to all pages fs7 16kb fs5 16kb fs3 16kb rs0 , 8kb page 0 page 2 page 1 2000h 0000h 8000h ffffh system i/o fs6 16kb fs4 16kb fs2 16kb fs1 , 16kb common memory to all pages c000h 4000h csiop 256b ai09173
upsd34xx psd module 193/293 table 103. hdl statement example generated from psdsoft express for memory map figure 65. psdsoft express memory mapping 28.2.4 eeprom emulation eeprom emulation is needed if it is desired to repeatedly ch ange only a small number of bytes of data in flash memory. in this case eeprom emulation is needed because although flash memory can be written byte-by-byte, it must be erased sector-by-sector, it is not erasable byte-by-byte (unlike eeprom whic h is written and erased byte-by-byte). so changing one or two bytes in flash memory typically requires erasing an entire sector each time only one byte is changed within that sector. however, two of the 8k byte sectors of secondary flash memory may be used to emulate eeprom by using a linked-list software techni que to create a sma ll data set that is rs0 = ((address ^h0000) & (address ^h1fff)); csiop = ((address ^h2000) & (address ^h20ff)); fs0 = ((address ^h0000) & (address ^h3fff)); fs1 = ((address ^h4000) & (address ^h7fff)); fs2 = ((page == 0) & (address ^h8000) & (address ^hbfff)); fs3 = ((page == 0) & (address ^hc000) & (address ^hffff)); fs4 = ((page == 1) & (address ^h8000) & (address ^hbfff)); fs5 = ((page == 1) & (address ^hc000) & (address ^hffff)); fs6 = ((page == 2) & (address ^h8000) & (address ^hbfff)); fs7 = ((page == 2) & (address ^hc000) & (address ^hffff)); csboot0 = ((address ^h8000) & (address ^h9fff)); csboot1 = ((address ^ha000) & (address ^hbfff)); csboot2 = ((address ^hc000) & (address ^hdfff)); csboot3 = ((address ^he000) & (address ^hffff));
psd module upsd34xx 194/293 maintained by alternating between the two flash sectors. for example, a data set of 128 bytes is written and maintained by software in a distributed fashion across one 8k byte sector of secondary flash memory until it becomes full. then the writing continues on the other 8k byte sector while erasing the first 8k byte sector. this process repeats continuously, bouncing back and forth between the two 8k byte sectors. this creates a wear-leveling effect, which increases the effective number of erase cycles for a data set of 128 bytes to many times more than the base 100k erase cycles of the flash memory. eeprom emulation in flash memory is typica lly faster than writing to actual eeprom memory, and more reliable because the last know n value in a data set is maintained even if a write cycle is corrupted by a power outa ge. the eeprom emulation function can be called by the user?s firmware, making it appear that the user is writing a single byte, or data record, thus hiding all of the data management that occurs within the two 8k byte flash sectors. eeprom emulation firmware for the upsd34xx is available from www.st.com/psm. 28.2.5 alternative mapping schemes here are more possible memory maps for the upsd3433. note: mapping examples would be slightly differ ent for upsd3433 and upsd3434, because of the different sizes of individual flash memory sectors. figure 66 place the larger main flash memory into program space, but split the secondary flash in half, placing two of its sectors into xdata space and remaining two sectors into program space. this method allows the designer to put iap code (or boot code) into two sectors of secondary flash in program space, and use the other two secondary flash sectors for data storag e, such as eeprom emulation in xdata space. figure 67 place both the main and secondary flash memories into program space for maximum code storage, with no flash memory in xdata space. figure 66. mapping: split second flash in half 0000h 8000h 4000h 6000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot1 , 8kb common memory to all pages csboot0 , 8kb common memory to all pages csboot2 8kb csboot3 8kb page x rs0 , 8kb csiop , 256b fs7 16kb fs3 16kb fs1 16kb page 0 page 1 page 2 page 3 2000h 0000h 8000h ffffh nothing mapped fs6 16kb fs5 16kb fs4 16kb fs2 16kb fs0 16kb system i/o system i/o c000h 2100h 4000h 2000h ai09174
upsd34xx psd module 195/293 figure 67. mapping: all flash in code space figure 68 place the larger main flash memory into xdata space and the smaller secondary flash into program space for systems that need a large amount of flash for data recording or large look-up tables, and not so much flash for 8032 firmware. figure 68. mapping: small code / big data it is also possible to ?reclassify? the flash memories during runtime, moving the memories between xdata memory space and program memory space on-the-fly. this essentially means that the user can override the initial setting during run-time by writing to a csiop register (the vm register). this is useful for iap, because standard 8051 architecture does not allow writing to program space. for example, if the user wants to update firmware in main flash memory that is residing in progra m space, the user can temporarily ?reclassify? the main flash memory into xdata space to erase and rewrite it while executing iap code 0000h 8000h 4000h 6000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot1 , 8kb common memory to all pages csboot0 , 8kb common memory to all pages csboot2 , 8kb common memory to all pages csboot3 , 8kb common memory to all pages page x rs0 , 8kb csiop , 256b fs7 16kb fs3 16kb fs1 16kb page 0 page 1 page 2 page 3 2000h 0000h ffffh fs6 16kb fs5 16kb fs4 16kb fs2 16kb fs0 16kb system i/o c000h 2100h 2000h ai09175 0000h 8000h 4000h 6000h ffffh 8032 xdata space (rd and wr) 8032 program space (psen) csboot0 8kb csboot1 8kb csboot2 8kb csboot3 8kb page x rs0 , 8kb common memory to all pages csiop , 256 bytes, common to all pages fs7 16kb fs3 16kb fs1 16kb page 0 page 1 page 2 page 3 2000h 0000h 8000h ffffh nothing mapped fs6 16kb fs5 16kb fs4 16kb fs2 16kb fs0 16kb system i/o c000h 2100h 2000h ai09176
psd module upsd34xx 196/293 from the secondary flash memory in program space. after the writing is complete, the main flash can be ?reclassified? back to program space, then execution can continue from the new code in main flash memory. the mapping example of figure 68 will accommodate this operation. 28.2.6 memory sector select rules when defining sector select signals (fsx, csbootx, rs0, csiop, pselx) in psdsoft express, the user must keep these rules in mind: main flash and secondary flash memory sector select signals may not be larger than their physical sector size as defined in table 101 on page 187 . any main flash memory sector select may not be mapped in the same address range as another main flash sector select (cannot overlap segments of main flash on top of each other). any secondary flash memory sector select may not be mapped in the same address range as another secondary flash sector select (cannot overlap segments of secondary flash on top of each other). a secondary flash memory sector may overlap a main flash memory sector. in the case of overlap, priority is given to the secondary flash memory sector. sram, csiop, or pselx may overlap any flash memory sector. in the case of overlap, priority is given to sram, csiop, or pselx. note: pselx is for optional peri pheral i/o mode on port a. the address range for sector selects for sram, pselx, a nd csiop must not overlap each other as they have the same priority, causing contention if overlapped. figure 69 illustrates the priority scheme of the memory elements of the psd module. priority refers to which memory will ultimately produce a byte of data or code to the 8032 mcu for a given bus cycle. any memory on a higher level can overlap and has priority over any memory on a lower level. memories on the same level must not overlap. example: fs0 is valid when the 8032 produces an address in the range of 8000h to bfffh. csboot0 is valid from 8000h to 9fffh. rs0 is valid from 8000h to 87ffh. any address from the 8032 in the range of rs0 always accesses the sram. any address in the range of csboot0 greater than 87ffh (and less than 9fffh) automatically addresses secondary flash memory. any address greater than 9fffh accesses main flash memory. one-half of the main flash memory segment and one-fourth of the secondary flash memory segment cannot be accessed by the 8032. figure 69. psd module memory priority level 1 sram, csiop, and peripheral i/o mode highest priority level 2 secondary flash memory level 3 main flash memory lowest priority ai02867e
upsd34xx psd module 197/293 28.2.7 the vm register one of the csiop registers (the vm register) controls whether or not the 8032 bus control signals rd , wr , and psen are routed to the main flash memory, or the secondary flash memory. routing of these signals to these psm module memories determines if memories reside in 8032 program address space, 8032 xdata space, or both. the initial setting of the vm register is determined by a choice in psdsoft express and programmed into the upsd34xx in a non-volatile fashion using jtag. this initial setting is loaded into the vm register upon power-up and also loaded upon any reset event. however, the 8032 may override the initial vm register setting at run-time by writing to the vm register, which is useful for iap. table 104 on page 197 defines bit functions within the vm register. note: bit 7, pio_en, is not related to the memory manipulation functions of bits 1, 2, 3, and 4. sram and csiop registers are always in xdata space and cannot reside in program space. figure 70 on page 198 illustrates how the vm regist er affects the routing of rd , wr , and psen to the memories on the psd module. as an example, if we apply the value 0ch to the vm register to implement the memory map example shown in figure 64 on page 192 , then the routing of rd , wr , and psen would look like that shown in figure 71 on page 198 . in this example, the configuration is specifie d in psdsoft express and programmed into the upsd34xx using jtag. upon power-on or any reset condition, the non-volatile value 0ch is loaded into the vm register. at runtime, the value 0ch in the vm register may be changed (overridden) by the 8032 if desired to implement iap or other functions. table 104. vm register (address = csiop + offset e2h) note: 1 default value of bits 1, 2, 3, and 4 is loaded from non-volatile setting as specified from psdsoft express upon any reset or power-up condition. the default value of these bits can be overridden by 8032 at run-time. 2 default value of bit 7 is zero upon any reset condition. bit 7 pio_en bit 6 bit 5 bit 4 main flash xdata space bit 3 secondary flash xdata space bit 2 main flash program space bit 1 secondary flash program space bit 0 0 = disable peripheral i/o mode on port a not used not used 0 = rd or wr cannot access main flash 0 = rd or wr cannot access secondary flash 0 = psen cannot access main flash 0 = psen cannot access secondary flash not used 1 = enable peripheral i/o mode on port a not used not used 1 = rd or wr can access main flash 1 = rd or wr can access secondary flash 1 = psen can access main flash 1 = psen can access secondary flash not used
psd module upsd34xx 198/293 figure 70. vm register control of memories figure 71. vm register example corresponding to memory map example 28.3 psd module data bus width the psd module functions as an 8-bit device to the mcu module except when the pfq is fetching instructions from th e flash memory. when psen is active, the psd module always drives 16-bit data out onto the bus. dpld main flash memory secondary flash memory cs cs fs0 - fs7 csboot0 - csboot3 wr vm reg bit 4 vm reg bit 3 vm reg bit 1 vm reg bit 2 rd wr oe wr oe 8032 address 53 other pld inputs psen ai10455 dpld main flash memory secondary flash memory cs cs fs0 - fs7 csboot0 - csboot3 wr oe wr oe 8032 address 53 other pld inputs wr psen rd vm register = 0ch ai10456
upsd34xx psd module 199/293 the flash memories are 16-bit wide when it is in program memory space and are 8-bit wide when it is in the data space. when the fl ash memory is configured in both ?program space? and ?data space,? the flash will drive 16-bit in a psen cycle and operates as an 8- bit memory in read or write cycle. the sram, csiop, and external device are always in 8-bit data space. table 105. data width in different bus cycles note: x = na 28.4 runtime control register definitions (csiop) the 39 csiop registers are defined in ta bl e 1 0 6 . the 8032 can access each register by the address offset (specified in ta bl e 1 0 6 ) added to the csiop base address that was specified in psdsoft express. do not write to unused locations within the csiop block of 256 registers, they should remain logic zero. table 106. csiop registers and their offsets (in hexadecimal) type of bus cycle main flash secondary flash sram csiop external device psen cycle (program memory) 16-bit 16-bit x x x read or write cycle (data memory) 8-bit 8-bit 8-bit 8-bit 8-bit flash programming cycle (flash write or reading status) 8-bit8-bitxxx register name port a (80-pin) port b port c port d other description link data in 00h 01h 10h 11h mcu i/o input mode. read to obtain current logic level of pins on ports a, b, c, or d. no writes. table 122 on page 228 control 02h 03h selects mcui/o or latched address out mode. logic 0 = mcu i/o, 1 = 8032 addr out. write to select mode. read for status. table 134 on page 232 data out 04h 05h 12h 13h mcu i/o output mode. write to set logic level on pins of ports a, b, c, or d. read to check status. this register has no effect if a port pin is driven by an omc output from pld. table 126 on page 229 direction 06h 07h 14h 15h mcu i/o mode. configures port pin as input or output. write to set direction of port pins. logic 1 = out, logic 0 = in. read to check status. table 130 on page 229
psd module upsd34xx 200/293 drive select 08h 09h 16h 17h write to configure port pins as either cmos push-pull or open drain on some pins, while selecting high slew rate on other pins. read to check status. default output type is cmos push-pull. table 136 on page 235 input macrocells 0ah 0bh 18h read to obtain logic state of imcs. no writes. table 117 on page 224 enable out och 0dh 1ah 1bh read state of output enable logic on each i/o port driver. 1 = driver output is enabled, 0 = driver is off, and it is in high impedance state. no writes. table 140 on page 236 output macrocells ab (mcellab) 20h read logic state of mcellab outputs (bank of eight omcs). write to load mcellab flip- flops. table 113 on page 222 output macrocells bc (mcellbc) 21h read logic state of mcellbc outputs (bank of eight omcs). write to load mcellbc flip- flops. table 114 on page 222 mask macrocells ab 22h write to set mask for mcellab. logic '1' blocks reads/writes of omc. logic '0' will pass omc value. read to check status. table 115 on page 223 mask macrocells bc 23h write to set mask for mcellbc. logic '1' blocks reads/writes of omc. logic '0' will pass omc value. read to check status. table 116 on page 223 main flash sector protection c0h read to determine main flash sector protection setting (non- volatile) that was specified in psdsoft express. no writes. table 109 on page 212 security bit and secondary flash sector protection c2h read to determine if psd module device security bit is active (non-volatile) logic 1 = device secured. also read to determine secondary flash protection setting (non- volatile) that was specified in psdsoft. no writes. table 110 on page 212 pmmr0 b0h power management register 0. write and read. table 144 on page 243 register name port a (80-pin) port b port c port d other description link
upsd34xx psd module 201/293 28.5 psd module detailed operation specific details are given here for the following key functional areas on the psd module: flash memories plds (dpld and gpld) i/o ports power management jtag isp and debug interface 28.5.1 flash memory operation the flash memories are accessed through the 8032 address, data, and control bus interfaces. flash memories (and sram) cannot be accessed by any other bus master other than the 8032 mcu (these are not dual-port memories). the 8032 cannot write to flash memory as it would an sram (supply address, supply data, supply wr strobe, assume the data was correctly written to memory). flash memory must first be ?unlocked? with a special instruction sequence of byte write operations to invoke an internal algorithm inside either flash memory array, then a single data byte is written (programmed) to the flash memory array, then programming status is checked by a byte read operation or by checking the ready/busy pin (pc3). table 107 on page 203 lists all of the special instruction sequences to program a byte to either of the flash memory arrays, erase the arrays, and check for different types of status from the arrays. this unlocking sequence is typical for many flash memories to prevent accidental writes by errant code. however, it is possible to by pass this unlocking sequen ce to save time while intentionally programming flash memory. pmmr2 b4h power management register 2. write and read. table 145 on page 244 pmmr3 c7h power management register 3. write and read. however, bit 1 can be cleared only by a reset condition. table 146 on page 244 page e0h memory page register. write and read. ta b l e 6 3 on page 188 vm (virtual memory) e2h places psd module memories into 8032 program address space and/or 8032 xdata address space. (vm overrides initial non-volatile setting that was specified in psdsoft express. reset restores initial setting) table 104 on page 197 register name port a (80-pin) port b port c port d other description link
psd module upsd34xx 202/293 important note: the 8032 may not read and execute code from the same flash memory array for which it is directing an instruction sequence. or more simply stated, the 8032 may not read code from the same flash array that is writing or erasing. instead, the 8032 must execute code from an alternate memory (like sram or a different flash array) while sending instruction sequences to a given flash array. since the two flash memory arrays inside the psd module device are completely independent, the 8032 may read code from one array while sending instructions to the other. it is possible, however, to suspend a sector erase operation in one particular flash array in order to access a different sector within that same flash array, then resume the erase later. after a flash memory array is programmed or erased it will go to ?read array? mode, then the 8032 can read from flash memory just as it would read from any rom or sram device. 28.5.2 flash memory instruction sequences an instruction sequence consists of a seque nce of specific byte write and byte read operations. each byte written to either flash memory array on the psd module is received by a state machine inside the flash array and sequentially decoded to execute an embedded algorithm. the algorithm is executed when the correct number of bytes are properly received and the time between two consecutive bytes is shorter than the time-out period of 80s. some instruction sequences are structured to include read operations after the initial write operations. an instruction sequence must be followed exac tly. any invalid combin ation of instruction bytes or time-out between two consecutive by tes while addressing flash memory resets the psd module flash logic into read array mode (where flash memory is read like a rom device). the flash memories support instruction sequences summarized in table 107 on page 203 . program a byte unlock sequence bypass erase memory by array or by sector suspend or resume a sector erase reset to read array mode the first two bytes of an instruction sequence are 8032 bus write operations to ?unlock? the flash array, followed by writing a command byte. the bus operations consist of writing the data aah to address x555 h during the first bus cycle a nd data 55h to address xaaah during the second bus cycle. 8032 address signals a12-a15 are ?don?t care? during the instruction sequence during write cycles. however, the appropriate sector select signal ( fsx or csbootx ) from the dpld must be active during the entire instruction sequence to complete the entire 8032 address (this includes the page number when memory paging is used). ignoring a12-a15 mean s the user has more flexibilit y in memory mapping. for example, in many traditional flash memories, instruction sequences must be written to addresses aaaah and 5555h, not xaaah and x 555h like supported on the psd module. when the user has to write to aaaah and 5555 h, the memory mapping options are limited. the main flash and secondary flash memories each have the same instruction set shown in table 107 on page 203 , but the sector select signals determine which memory array will receive and execute the instructions.
upsd34xx psd module 203/293 table 107. flash memory instruction sequences (1,2) note: 1 all values are in hexadecimal, x = don?t care 2 8032 addresses a12 through a15 are ?don?t care? during the instruction sequence decoding. only address bits a0-a11 are used during decoding of flash memory instruction instr. seq. bus cycle 1 bus cycle 2 bus cycle 3 bus cycle 4 bus cycle 5 bus cycle 6 bus cycle 7 link read memory contents (read array mode) read byte from any valid flash memory addr read memory contents. on page 204 program (write) a byte to flash memory write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write a0h to x555h ( command ) write data byte to address programming flash memory. on page 205 bypass unlock write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 20h to x555h ( command ) bypassed unlock sequence on page 209 program a byte to flash memory with bypassed unlock write a0h to xxxxh ( command ) write data byte to address bypassed unlock sequence on page 209 reset bypass unlock write 90h to xxxxh ( command ) write 00h to xxxxh ( command ) bypassed unlock sequence on page 209 flash bulk erase (3) write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 80h to x555h ( command ) write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 10h to x555h ( command ) flash bulk erase on page 209 flash sector erase write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 80h to x555h ( command ) write aah to x555h ( unlock ) write 55h to xaaah ( unlock ) write 30h to desired sector ( command ) write 30h to another sector ( command ) flash sector erase on page 210 suspend sector erase write b0h to address that activates fsx or csbootx where erase is in progress ( command ) suspend sector erase on page 210 resume sector erase write 30h to address that activates fsx or csbootx where desired to resume erase ( command ) resume sector erase on page 211 reset flash write f0h to address that activates fsx or csbootx in desired array. ( command ) reset flash on page 211
psd module upsd34xx 204/293 sequences. the individual sector select signal (fs0 - fs7 or csboot0-csboot3) which is active during the instruction sequ ence determines the complete address. 3 directing this command to any individual sector within a flash memory array will invoke the bulk erase of all flash memory sectors within that array. 28.5.3 reading flash memory under typical conditions, the 8032 may read the flash memory using read operations (read bus cycles) just as it would a rom or ram device. alternately, the 8032 may use read operations to obtain status information about a program or erase operation that is currently in progress. the following sections describe the kinds of read operations. 28.5.4 read memory contents. flash memory is placed in the read array mode after power-up, after a psd module reset event, or after receiving a reset flash memory instruction sequence from the 8032. the 8032 can read flash memory contents using standard read bus cycles anytime the flash array is in read array mode. flash memories will always be in re ad array mode when the array is not actively engaged in a program or erase operation. 28.5.5 reading the eras e/program status bits the flash arrays provide several status bits to be used by the 8032 to confirm the completion of an erase or program operation on flash memory, shown in ta b l e 1 0 8 o n page 206 . the status bits can be read as many times as needed until an operation is complete. the 8032 performs a read operation to obtain these status bits while an erase or program operation is being executed by the stat e machine inside each flash memory array. 28.5.6 data polling flag (dq7) while programming either flash memory, the 8032 may read the data polling flag bit (dq7), which outputs the complement of the d7 bit of the byte being programmed into flash memory. once the program operation is complete, dq7 is equal to d7 of the byte just programmed into flash memory, indicating the program cycle has completed successfully. the correct select signal, fsx or csbootx, must be active during the entire polling procedure. polling may also be used to indicate when an erase operation has co mpleted. during an erase operation, dq7 is '0.' after the erase is complete dq7 is '1.' the correct select signal, fsx or csbootx, must be active during the entire polling procedure. dq7 is valid after the fourth instruction byte write operation (for program instruction sequence) or after the sixth instruction byte write operation (for erase instruction sequence). if all flash memory sectors to be erased are protected, dq7 is reset to ?0? for about 100s, and then dq7 returns to the value of d7 of the previously addressed byte. no erasure is performed.
upsd34xx psd module 205/293 28.5.7 toggle flag (dq6) the flash memories offer an alternate way to determine when a flash memory program operation has completed. during the program operation and while the correct sector select fsx or csbootx is active, the toggle flag bit (dq6) toggles from '0' to '1' and '1' to ?0? on subsequent attempts to read any byte of the same flash array. when the internal program operation is complete, the toggling stops and the data read on the data bus d0-7 is the actual value of the addressed memory byte. the device is now accessible for a new read or write operation. the operation is finished when two successive reads yield the same value for dq6. dq6 may also be used to indicate when an erase operation has completed. during an erase operation, dq6 will toggle from '0 ' to '1' and '1' to ?0? until t he erase operation is complete, then dq6 stops toggling. the erase is finished when two successive reads yield the same value of dq6. the correct sector select signal, fsx or csbootx, must be active during the entire procedure. dq6 is valid after the fourth instruction byte write operation (for program instruction sequence) or after the sixth instruction byte write operation (for erase instruction sequence). if all the flash memory sectors selected for erasure are protected, dq6 toggles to ?0? for about 100s, then returns value of d6 of the previously addressed byte. error flag (dq5). during a normal program or erase operation, the error flag bit (dq5) is to ?0?. this bit is set to ?1? when there is a failure during flash memory byte program, sector erase, or bulk erase operations. in the case of flash memory programming, dq5 bit indicates an attempt to program a flash memory bit from the programmed state of '0,' to the erased state of 1, which is not valid. dq5 may also indicate a particular flash cell is damaged and cannot be programmed. in case of an error in a flash memory sector erase or byte program operation, the flash memory sector in which the error occurred or to which the programmed byte belongs must no longer be used. other flash memory se ctors may still be used. dq5 is reset after a reset flash instru ction sequence. 28.5.8 erase time-out flag (dq3) the erase time-out flag bit (dq3) reflects the time-out period allowed between two consecutive sector erase instruction sequence bytes. if multiple sector erase commands are desired, the additional sector erase commands (30h) must be sent by the 8032 within 80us after the previous sector erase command. dq3 is 0 before this time period has expired, indicating it is ok to issue additional sector erase commands. dq3 will go to logic ?1? if the time has been longer than 80s since the previous sector erase command (time has expired), indication that is not ok to send another sector erase command. in this case, the 8032 must start a new sector erase instruction sequence (unlock and command) beginning again after the current sector erase operation has completed. 28.5.9 programming flash memory. when a byte of flash memory is programmed, in dividual bits are programmed to logic '0.' cannot program a bit in flash memory to a logic ?1? once it has been programmed to a logic '0.' a bit must be erased to logic ?1?, and programmed to logic '0.' that means flash memory must be erased prior to being programmed. a byte of flash memory is erased to all 1s
psd module upsd34xx 206/293 (ffh). the 8032 may erase the entire flash me mory array all at once, or erase individual sector-by-sector, but not erase byte-by-byte. however, even though the flash memories cannot be erased byte-by-byte, the 8032 may program flash memory byte-by-byte. this means the 8032 does not need to program group of bytes (64, 128, etc.) at one time, like some flash memories. each flash memory requires the 8032 to send an instruction sequence to program a byte or to erase sectors (see table 107 on page 203 ). if the byte to be programmed is in a protected flash memory sector, the instruction sequence is ignored. important note: it is mandatory that a chip-selec t signal is active for the flash sector where a programming instruction sequence is targeted. the user must make sure that the correct chip-select equation, fsx or csbootx specif ied in psdsoft express matches the address range that the 8032 fi rmware is accessing, otherwise the instruction sequence will not be recognized by the flash array. if memory paging is used, be sure that the 8032 firmware sets the page register to the correct page number before issuing an instruction sequence to the flash memory segment on a particular memory page, otherwise the correct sector select signal will not become active. once the 8032 issues a flash memory program or erase instruction sequence, it must check the status bits for completion. the embedded algorithms that are invoked inside a flash memory array provide several ways to give status to the 8032. status may be checked using any of three methods: data polling, data togg le, or ready/busy (pin pc3). table 108. flash memory status bit definition note: 1 x = not guaranteed value, can be read either '1' or '0.' 2 dq7-dq0 represent the 8032 data bus bits, d7-d0. 28.5.10 data polling polling on the data polling flag bit (dq7) is a method of checking whether a pr ogram or erase operation is in progress or has completed. figure 72 shows the data polling algorithm. when the 8032 issues a program instruction sequence, the embedded algorithm within the flash memory array begins. the 8032 then reads the location of the byte to be programmed in flash memory to check status. the data po lling flag bit (dq7) of this location becomes the compliment of bit d7 of the original data byte to be programmed. the 8032 continues to poll this location, comparing th e data polling flag bi t (dq7) and monitori ng the error flag bit (dq5). when the data polling flag bit (dq7) matches bit d7 of the original data, then the embedded algorithm is complete. if the error flag bit (dq5) is '1,' the 8032 should test the data polling flag bit (dq7) again since the data polling flag bit (dq7) may have changed simultaneously with the error flag bit (dq5) (see figure 72 ). the error flag bit (dq5) is set if either an internal time-out occurred while the embedded algorithm attempted to program the byte (indicating a bad flash cell) or if the 8032 functional block fsx, or csbootx dq7 dq 6 dq5 dq4 dq3 dq2 dq1 dq0 flash memory active (the desired segment is selected) data polling to g g l e flag error flag x erase time- out xxx
upsd34xx psd module 207/293 attempted to program bit to logic ?1? when that bit was already programmed to logic ?0? (must erase to achieve logic ?1?). it is suggested (as with all flash memories) to read the location again after the embedded programming algorithm has completed, to compare the byte that was written to the flash memory with the byte that was intended to be written. when using the data polling meth od during an erase operation, figure 72 still applies. however, the data polling flag bi t (dq7) is '0' until the erase operation is complete. a ?1? on the error flag bit (dq5) indicates a time-out condition on the erase cycle, a ?0? indicates no error. the 8032 can read any lo cation within the sector being erased to get the data polling flag bit (dq7) and the error flag bit (dq5). figure 72. data polling flowchart 28.5.11 data toggle checking the toggle flag bit (dq6) is another method of determining whether a program or erase operation is in progress or has completed. figure 73 shows the data toggle algorithm. when the 8032 issues a program instruction sequence, the embedded algorithm within the flash memory array begins. the 8032 then reads the location of the byte to be programmed in flash memory to check status. the toggle flag bit (dq6) of this location toggles each time the 8032 reads this location until the embedded algorithm is complete. the 8032 continues to read this location, checking the toggle flag bit (dq6) and monitoring the error flag bit (dq5). when the toggle flag bit (dq6 ) stops toggling (two consecutive reads yield the same value), then the embedded algorithm is complete. if the error flag bit (dq5) is '1,' read dq5 & dq7 at valid address start read dq7 fail pass ai01369b dq7 = data yes no yes no dq5 = 1 dq7 = data yes no
psd module upsd34xx 208/293 the 8032 should test the toggle flag bit (dq6) again, since the toggle flag bit (dq6) may have changed simultaneously with the error flag bit (dq5) (see figure 73 ). the error flag bit (dq5) is set if either an internal time-out occurred while the embedded algorithm attempted to program the byte, or if the 8032 attempted to program bit to logic ?1? when that bit was already programmed to logic ?0? (must erase to achieve logic ?1?). it is suggested (as with all flash memories) to read the location again after the embedded programming algorithm has completed, to compare the byte that was written to flash memory with the byte that was intended to be written. when using the data toggle method during an erase operation, figure 73 still applies. the toggle flag bit (dq6) toggles until the erase operation is complete. a ?1? on the error flag bit (dq5) indicates a time-out condition on the erase cycle, a ?0? indicates no error. the 8032 can read any location within the sector being erased to get the toggle flag bit (dq6) and the error flag bit (dq5). psdsoft express generates ansi c code functions the user may use to implement these data toggling algorithms. figure 73. data toggle flowchart 28.5.12 ready/busy (pc3) this signal can be used to output the ready/busy status of a program or erase operation on either flash memory. the output on the ready/busy pin is a ?0? (busy) when either flash memory array is being written, or when either flash memory array is being erased. the output is a ?1? (ready) when no program or erase operation is in progress. to activate this function on this pin, the user must select the ?ready/busy ? selection in psdsoft express when configuring pin pc3. this pin may be polled by the 8032 or used as a 8032 interrupt to read dq5 & dq6 start read dq6 fail pass ai01370b dq6 = toggle no no yes yes dq5 = 1 no yes dq6 = toggle
upsd34xx psd module 209/293 indicate when an erase or program operation is complete (requires routing the signal on pc board from pc3 back into a pin on the mcu module). this signal is also available internally on the psd module as an input to both plds (without routing a signal externally on pc board) and its signal name is ?rd_bsy?. the ready/busy output can be probed during lab development to check the timing of flash memory programming in the system at run-time. 28.5.13 bypassed unlock sequence the bypass unlock mode allows the 8032 to program bytes in the flash memories faster than using the standard flash program instru ction sequences because the typical aah, 55h unlock bus cycles are bypassed for each byte that is programmed. bypassing the unlock sequence is typically used when the 8032 is intentionally programming a large number of bytes (such as during iap). after intentional programming is complete, typically the bypass mode would be disabled, and full protection is back in place to prevent unwanted writes to flash memory. the bypass unlock mode is entered by first init iating two unlock bus cycles. this is followed by a third write operation containing the bypass unlock command, 20h (as shown in table 107 on page 203 ). the flash memory array that received that sequence then enters the bypass unlock mode. after this, a two bus cycle program operation is all that is required to program a byte in this mode. the first bu s cycle in this shortened program instruction sequence contains the bypassed unlocked program command, a0h, to any valid address within the unlocked flash array. the second bus cycle contains the address and data of the byte to be programmed. programming status is checked using toggle, polling, or ready/busy just as before. additional data bytes are programmed the same way until this bypass unlock mode is exited. to exit bypass unlock mode, the system must issue the reset bypass unlock instruction sequence. the first bus cycle of this instructio n must write 90h to any valid address within the unlocked flash array; the second bus cycle must write 00h to any valid address within the unlocked flash array. after this sequence the flash returns to read array mode. during bypass unlock mode, only the bypassed unlock program instru ction, or the reset bypass unlock instruction is valid , other instruction will be ignored. 28.5.14 erasing flash memory flash memory may be erased sector-by-sector, or an entire flash memory array may be erased with one command (bulk). 28.5.15 flash bulk erase the flash bulk erase instruction sequence us es six write operations followed by a read operation of the status register, as described in table 107 on page 203 . if any byte of the bulk erase instruction sequence is wrong, the bulk erase instruction sequence aborts and the device is reset to the read array mode. the address provided by the 8032 during the flash bulk erase command sequence may select any one of the eight flash memory sector select signals fsx or one of the four sig nals csbootx. an erase of the entire flash memory array will occur in a particular array even though a command was sent to just one of the individual flash memory sectors within that array. during a bulk erase, the memory status may be checked by reading the error flag bit (dq5), the toggle flag bit (dq6), and the da ta polling flag bit (dq7 ). the error flag bit (dq5) returns a ?1? if there has been an erase failure. details of acquiring the status of the
psd module upsd34xx 210/293 bulk erase operation are detailed in the section entitled ? section 28.5.9: programming flash memory. on page 205 . during a bulk erase operation, the flash memory does not accept any other flash instruction sequences. 28.5.16 flash sector erase the sector erase instruction sequence uses six write operations, as described in table 107 on page 203 . additional flash sector erase commands to other sectors within the same flash array may be issued by the 8032 if the additional commands are sent within a limited amount of time. the erase time-out flag bit (dq3) reflects the time-out period allowed between two consecutive sector erase instruction sequence bytes. if multiple sector erase commands are desired, the additional sector erase commands (30h) must be sent by the 8032 to another sector within 80s after the previous sector erase command. dq3 is 0 before this time period has expired, indicating it is ok to issue additional sector erase commands. dq3 will go to logic ?1? if the time has been longer than 80s since the previous sector erase command (time has expired), indicating that is not ok to send another sector erase command. in this case, the 8032 must start a new sector erase instruction sequence (unlock and command), beginning again after the current sector erase operation has completed. during a sector erase operation, the memory status may be checked by reading the error flag bit (dq5), the toggle flag bit (dq6), and the da ta polling flag bit (d q7), as detailed in section 28.5.5: reading the erase/program status bits on page 204 . during a sector erase operation, a flash memory accepts only reset flash and suspend sector erase instruction sequences. erasure of one flash memory sector may be suspended, in order to read data from another flash memory sector, and then resumed. the address provided with the initial flash sector erase command sequence ( table 107 on page 203 ) must select the first desired sector (fsx or csbootx) to erase. subsequent sector erase commands that are appended within the time-out period must be addressed to other desired segments within the same flash memory array. 28.5.17 suspend sector erase when a sector erase operation is in progress, the suspend sector erase instruction sequence can be used to suspend the operation by writing b0h to any valid address within the flash array that currently is undergoing an erase operation. this allows reading of data from a different flash memory sector within the same array after the erase operation has been suspended. suspend sector erase is accepted only during an erase operation. there is up to 15s delay after the suspend sector erase command is accepted and the array goes to read array mode . the 8032 will monitor the toggle flag bit (dq6) to determine when the erase operation has halted and read array mode is active.
upsd34xx psd module 211/293 if a suspend sector erase instruction sequence was executed, the following rules apply: attempting to read from a flash memory sector that was being erased outputs invalid data. reading from a flash memory sector that was not being erased is valid. the flash memory cannot be programmed, and only responds to resume sector erase and reset flash instruction sequences. if a reset flash instruction sequence is received, data in the flash memory sector that was being erased is invalid. 28.5.18 resume sector erase if a suspend sector erase instruction sequence was previously executed, the erase cycle may be resumed with this instruction sequence. the resume sector erase instruction sequence consists of writing the command 30h to any valid address within the flash array that was suspended as shown in table 107 on page 203 . 28.5.19 reset flash the reset flash instruction sequence resets the embedded algorithm running on the state machine in the targeted flash memory (main or secondary) and the memory goes into read array mode. the reset flash instruction consists of one bus write cycle as shown in table 107 on page 203 , and it must be executed after any error condition that has occurred during a flash memory program or erase operation. it may take the flash memory up to 25s to complete the reset cycle. the reset flash instruction sequence is ignored when it is issued during a program or bulk erase operation. the reset flash instruction sequence aborts any on-going sector erase operation and returns the flash memory to read array mode within 25s. 28.5.20 reset signal applied to flash memory whenever the psd module receives a reset signal from the mcu module, any operation that is occurring in either flash memory ar ray will be aborted and th e array(s) will go to read array mode. it may take up to 25s to abort an operation and achieve read array mode. a reset from the mcu module w ill result from any of these ev ents: an active signal on the upsd34xx reset_in input pin, a watchdog timer time-out, detection of low v cc , or a jtag debug channel reset event. 28.5.21 flash memory sector protection each flash memory sector can be separately protected against program and erase operations. this mode can be activated (or deactivated) by selecting this feature in psdsoft express and then programming through the jtag port. sector protection can be selected for individual sectors, and the 8032 cannot override the protection during run-time. the 8032 can read, but not change, sector protection. any attempt to program or erase a protected flash memory sector is ignored. the 8032 may read the contents of a flash sector even when a sector is protected. sector protection status is not read using flash memory instruction sequences, but instead this status is read by the 8032 reading two registers within csiop address space shown in ta bl e 109 and table 110 .
psd module upsd34xx 212/293 28.5.22 flash memory protection during power-up flash memory write operations are automatically prevented while v dd is ramping up until it rises above v lko voltage threshold at which time flash memory write operations are allowed. 28.5.23 psd module security bit a programmable security bit in the psd module protects its contents from unauthorized viewing and copying. the security bit is set using psdsoft express and programmed into the psd module with jtag. wh en set, the security bit will block access of jtag programming equipment from reading or modifying the psd module flash memory and pld configuration. the security bit also blocks jtag access to the mcu module for debugging. the only way to defeat the security bit is to erase the entire psd module using jtag (erase is the only jtag operation allowed while security bit is set), after which the device is blank and may be used again. the 8032 mcu will always have access to flash memory contents through its 8-bit data bus even while the security bit is set. the 8032 can read the status of the security bit at run-time (but it cannot change it) by reading the csiop register defined in ta b l e 1 1 0 . table 109. main flash memory protection register definition (address = csiop + offset c0h) note: bit definitions: sec_prot 1 = flash memory sector is write protected, 0 = flash memory sector is not write protected. table 110. secondary flash memory protection/security register definition (csiop + offset c2h) note: security_bit = 1, device is secured, 0 = not secured note: sec_prot 1 = flash memory sector is write protected, 0 = flash memory sector is not write protected. 28.5.24 plds the psd module contains two plds: the decode pld (dpld), and the general pld (gpld), as shown in figure 74 on page 215 . both plds are fed by a common pld input signal bus, and additionally, the gpld is connected to the 8032 data bus. pld logic is specified using psdsoft expres s and programmed into the psd module using the jtag isp channel. pld logic is non-volatile and available at power-up. plds may not be programmed by the 8032. the plds have selectable levels of performance and power consumption. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sec7_prot sec6_prot sec5_prot sec4_prot sec3_prot sec2_prot sec1_prot sec0_prot bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 security_bit not used not used not used sec3_prot sec2_prot sec1_prot sec0_prot
upsd34xx psd module 213/293 the dpld performs address decoding, and ge nerates select signals for internal and external components, such as memory, registers, and i/o ports. the dpld can generate external chip-select (ecs1-ecs2) signals on port d. the gpld can be used for logic functions, such as loadable counters and shift registers, state machines, encoding and decoding logic. these logic functions can be constructed from a combination of 16 output macrocells (omc), 20 input macrocells (imc), and the and-or array. routing of the 16 omcs outputs can be divided between pins on three ports a, b, or c by the omc allocator as shown in figure 78 on page 221 . eight of the 16 omcs that can be routed to pins on port a or port b and are named mcellab0-mcellab7. the other eight omcs to be routed to pins on port b or port c and are named mcellbc0-mcellbc7. this routing depends on the pin number assignments that are specified in psdsoft express for ?pld outputs? in the pin definition section. omc outputs can also be routed internally (not to pins) used as buried nodes to create shifters, counters, etc. the and-or array is used to form product terms. these product terms are configured from the logic definitions entered in psdsoft express. a pld input bus consisting of 69 signals is connected to both plds. input signals are shown in ta bl e 1 1 1 , both the true and compliment versions of each of these signals are available at inputs to each pld. note: the 8032 data bus, d0 - d7, does not route directly to pld inputs. instead, the 8032 data bus has indirect access to the gpld (not the dpld) when the 8032 reads and writes the omc and imc registers within csiop address space. 28.5.25 turbo bit and plds the plds can minimize power consumption by going to standby after all the pld inputs remain unchanged for an extended time (about 70ns). when the turbo bit is set to logic one (bit 3 of the csiop pmmr0 register), turbo mode is turned off and then this automatic standby mode is achieved. turning off turbo mode increases propagation delays while reducing power consumption. the default state of the turbo bit is logic zero, meaning turbo mode is on. additionally, four bits are available in the csiop pmmr0 and pmmr2 registers to block the 8032 bus control signals (rd , wr , psen , ale) from entering the plds. this reduces power consumption and can be used only when these 8032 control signals are not used in pld logic equations. see section 28.5.51: power management on page 241 .
psd module upsd34xx 214/293 table 111. dpld and gpld inputs input source input name number of signals 8032 address bus a0-a15 16 8032 bus control signals psen , rd , wr , ale 4 reset from mcu module reset 1 power-down from auto-power down counter pdn 1 porta input macrocells (80-pin devices only) pa 0 - pa 7 8 portb input macrocells pb0-pb7 8 portc input macrocells pc2, pc3, pc4, pc7 4 port d inputs (52-pin devices have only pd1) pd1, pd2 2 page register pgr0-pgr7 8 macrocell omc bank ab feedback mcellab fb0-7 8 macrocell omc bank bc feedback mcellbc fb0-7 8 flash memory status bit ready/busy 1
upsd34xx psd module 215/293 figure 74. dpld and gpld gpld 20 input macrocells pld input bus pin feedback, ports a, b, c node feedback dpld main flash memory selects (fsx) aaaaaaaa bbbbbbbb c c c c 69 inputs omc allo- cator 4 or 8 2 or 4 secondary flash memory selects (csbootx) 1 sram select (rs0) 1 i/o port select (csiop) 2 periperal i/o mode range selects (pselx) 1 or 2 external device chip-selects (ecsx) 8 8 4 8 8 4 and-or array and-or array 8032 address 8032 bus control page register other signals 16 output macrocells port a (80-pin only) port c port b 8032 data bus pin feedback, port d port d 8032 data bus 8 pld out a b a b a b a b a b a b a b a b b c b c b c b c b c b c b c b c 8 pld out 69 inputs ai06600a
psd module upsd34xx 216/293 28.5.26 decode pld (dpld) the dpld ( figure 75 on page 217 ) generates the following memory decode signals: eight main flash memory sector select signals (fs0-fs7) with three product terms each four secondary flash memory sector select signals (csboot0-csboot3) with three product terms each one sram select signal (rs0) with two product terms one select signal for the base address of 256 psd module device control and status registers (csiop) with one product term two external chip-select output signals for port d pins, each with one product term (52- pin devices only have one pin on port d) two chip-select signals (psel0, psel1) used to enable the 8032 data bus repeater function (peripheral i/o mode) for port a on 80-pin devices. each has one product term. a product term indicates the logical or of two or more inputs. for example, three product terms in a dpld output means the final output signal is capable of representing the logical or of three different input signals, each input signal representing the logical and of a combination of the 69 pld inputs. using the signal fs0 for example, the user may create a 3-product term chip select signal that is logic true when any one of three diff erent address ranges are true... fs0 = address range 1 or address range 2 or address range 3. the phrase ?one product term? is a bit misleading, but commonly used in this context. one product term is the logical and of two or more inputs, with no or logic involved at all, such as the csiop signal in figure 75 on page 217 .
upsd34xx psd module 217/293 figure 75. dpld logic array 28.5.27 general pld (gpld) the gpld is used to create general system logic. figure 74 on page 215 shows the architecture of the entire gpld, and figure 76 on page 218 shows the relationship between one omc, one imc, and one i/o port pin, which is representative of pins on ports a, b, and c. it is important to understand how these elements work together. a more detailed description will follow for the three major blocks (omc, imc, i/o port) shown in figure 76 . figure 76 also shows which csiop registers to access for various pld and i/o functions. the gpld contains: 16 output macrocells (omc) 20 input macrocells (imc) omc allocator product term allocator inside each omc and-or array capable of generating up to 137 product terms three i/o ports, a, b, and c fs0 fs1 fs7 fs6 fs5 fs4 fs3 fs2 main flash memory sector selects csboot0 csboot3 csboot2 csboot1 secondary flash memory sector selects rs0 sram select csiop i/o & control registers select ecs0 ecs1 external chip- selects (port d) psel0 psel1 peripheral i/o mode range selects 8032 address (a0 - a15) 16 4 1 power-down indicator (pdn) 1 pin input ports a, b, c (imcs) 20 pin input port d 2 omc feedback (mcellab.fb0-7) 8 page register (pgr0 - pgr7) 8 8 1 omc feedback (mcellbc.fb0-7) pld input bus 3 3 3 3 3 3 3 3 3 3 3 3 2 1 1 1 1 1 number of product terms ai06601a psm module reset (rst) flash mem prog status (rdybsy) 8032 cntl (rd, wr, psen, ale)
psd module upsd34xx 218/293 figure 76. gpld: one omc, one imc, and one i/o port (typical pin, port a, b, or c) output macrocell (omc) input macrocell (imc) flip-flop clock global clock flip-flop clear node feedback native product terms product term allocator product terms from other omcs i/o port logic peripheral i/o mode bit output enable latched 8032 addr bit psd module port pin 8032 data bit 8032 data bit output enable pin feedback clock or gate signal pld input bus omc out ale to other i/o port logic omc allo- cator reset psd module reset from other macrocell allocator global clock and-or array clock or gate reset flip-flop and other logic borrowed product terms pin input latch or pass input signal 8032 data bits 8032 data bits csiop registers (data out, direction control, drive) m u x omc output feed back direction control data out csiop registers (data in, data out, direction, control, drive, enable) csiop registers (mcellab, mcellbc) read omc load omc csiop registers (imca, imcb, imcc) read imc flip-flop preset pin input data i n 69 inputs 8032 rd 8032 rd 8032 rd 8032 wr 8032 wr 8032 address, data, control bus ai06602a
upsd34xx psd module 219/293 28.5.28 output macrocell the gpld has 16 omcs. architecture of one individual omc is shown in figure 77 . omcs can be used for internal node feedback (buried registers to build shift registers, etc.), or their outputs may be routed to external port pins. the user can choose any mixture of omcs used for buried functions and omcs used to drive port pins. referring to figure 77 , for each omc there are native product terms available from the and-or array to form logic, and also borrowed product terms are available (if unused) from other omcs. the polarity of the final product term output is controlled by the xor gate. each omc can implement sequential logic using the flip-flop element, or combinatorial logic when bypassing the flip-flop as selected by the output multiplexer. an omc output can drive a port pin through the omc allocator, it can also drive the 8032 data bus, and also it can drive a feedback path to the and-or array inputs, all at the same time. the flip-flop in each omc can be synthesized as a d, t, jk, or sr type in psdsoft express. omc flip-flops are specified using psdsoft expr ess in the ?user defined nodes? section of the design assistant. each flip-flop?s clock, preset, and clear inputs may be driven individually from a product term of the and-or array, defined by equations in psdsoft express for signals *. c, *.pr, and *.re respectively. the preset and clear inputs on the flip- flops are level activated, active-high logic signals. the clock inputs on the flip-flops are rising-edge logic signals. optionally, the signal clkin (pin pd1) can be used for a common clock source to all omc flip-flops. each flip-flop is clocked on the rising edge. a common clock is specified in psdsoft express by assigning the function ?common clock input? for pin pd1 in the pin definition section, and then choosing the sign al clkin when specifying the clock input (*.c) for individual flip-flops in the ?user defined nodes? section.
psd module upsd34xx 220/293 figure 77. detail of a single omc 28.5.29 omc allocator outputs of the 16 omcs can be routed to a combination of pins on port a (80-pin devices only), port b, or port c as shown in figure 78 . omcs are routed to port pins automatically after specifying pin numbers in psdsoft expr ess. routing can occur on a bit-by-bit basis, spitting omc assignment between the ports. however, one omc can be routed to one only port pin, not both ports. 28.5.30 product term allocator each omc has a product term allocator as shown in figure 77 on page 220 . psdsoft express uses pt allocators to give and take product terms to and from other omcs to fit a logic design into the availabl e silicon resources. this ha ppens automatically in psdsoft express, but underst anding how pt allocation works will he lp if the logic design does not ?fit?, in which case the user may try selecting a different pin or different omc for the logic where more product terms may be availabl e. the following list summarizes how product terms are allocated to each omc, as shown in table 112 on page 221 . mcellab0-mcellab7 each have three native product terms and may borrow up to six more mcellbc0-mcellbc3 each have four native product terms and may borrow up to five more mcellbc4-mcellbc7 each have four native product terms and may borrow up to six more. d clr pre q mux mux m u x m u x psdsoft psdsoft output macrocell (omc) pt preset (.pr) from and-or array borrowed pts pt clear (.re) node feedback (.fb) polarity select, psdsoft pt allocator, draws from local and global unused product terms. psdsoft dictates. lended pts data bit from 8032 data bit to 8032 indicates mcu write to particular csio omc register mcu overrides pt preset and clr during mcu write mcu read of particular csiop omc register omc output from and-or array to pld input bus from and-or array native pts allocated pts pt clock (.c) from and-or array global clock (clkin) from pld input bus 8032 address, data, control bus omc allo- cator o u t product terms from other omcs ai06617a
upsd34xx psd module 221/293 native product terms come from the and-or array. each omc may borrow product terms only from certain other omcs, if they are not in use. product term allocation does not add any propagation delay to the logic. the fitter report generated by psdsoft express will show any pt allocation that has occurred. if an equation requires more product terms than are available to it through pt allocation, then ?external? product terms are required, which consumes other omcs. this is called product term expansion and also happens automatically in psdsoft express as needed. pt expansion causes additional propagation dela y because an additional omc is consumed by the expansion process and its output is rerouted (or fed back) into the and-or array. the user can examine the fitter report generated by psdsoft express to see resulting pt allocation and pt expansion (expansion will have signal names, su ch as ?*.fb_0? or ?*.fb_1?). psdsoft express will always try to fit the logic desig n first by using pt allocation, and if that is not sufficient then psdso ft express will use pt expansion. product term expansion may occur in the dpld for complex chip select equations for flash memory sectors and for sram, but this is a rare occurence. if psdsoft express does use pt expansion in the dpld, it results in an approximate 15ns additional propagation delay for that chip select signal, which gives 15ns less time for the memory to respond. be aware of this and consider adding a wait state to the 8032 bus access (using the sfr named, buscon), or lower the 8032 clock frequency to avoid problems with memory access time. figure 78. omc allocator table 112. omc port and data bit assignments omc port assignment (1,2) native product terms from and- or array maximum borrowed product terms data bit on 8032 data bus for loading or reading omc mcellab0 port a0 or b0 3 6 d0 mcellab1 port a1 or b1 3 6 d1 mcellab2 port a2 or b2 3 6 d2 mcellab3 port a3 or b3 3 6 d3 mcellab4 port a4 or b4 3 6 d4 mcellab5 port a5 or b5 3 6 d5 mcellab6 port a6 or b6 3 6 d6 mcellab7 port a7 or b7 3 6 d7 mcellbc0 port b0 4 5 d0 mcellbc1 port b1 4 5 d1 port c pins port b pins port a pins (80-pin pkg only) omc bank bc (mcellbc0-7) omc bank ab (mcellab0-7) 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 2 3 4 7 4 5 6 7 32 1 0 4 5 6 7 32 1 0 ** ** * = used for jtag, pin not available to gpld ai09177
psd module upsd34xx 222/293 note: 1 mcellab0-mcellab7 can be output to port a pins only on 80-pin devices. port a is not available on 52-pin devices 2 port pins pc0, pc1, pc5, and pc6 are dedicated jtag pins and are not available as outputs for mcellbc 0, 1, 5, or 6 28.5.31 loading and reading omcs each of the two omc groups (eight omcs ea ch) occupies a byte in csiop space, named mcellab and mcellbc (see ta bl e 1 1 3 and ta bl e 1 1 4 ). when the 8032 writes or reads these two omc registers in csiop it is access ing each of the omcs through its 8-bit data bus, with the bit assignment shown in table 112 on page 221 . sometimes it is important to know the bit assignment when the user builds gpld logic that is accessed by the 8032. for example, the user may create a 4-bit counter that must be loaded and read by the 8032, so the user must know which nibble in the corresponding csiop omc register the firmware must access. the fitter report generated by psdso ft express will indicate how it assigned the omcs and data bus bits to the logic. the user can optionally force psdsoft express to assign logic to specific omcs and data bu s bits if desired by using the ?property? statement in psdsoft express. please see the psdsoft express user?s manual for more information on omc assignments. loading the omc flip-flops with data from the 8032 takes priority over the pld logic functions. as such, the preset, clear, and clock inputs to the flip-flop can be asynchronously overridden when the 8032 writes to the csiop registers to load the individual omcs. table 113. output macrocell mcellab (address = csiop + offset 20h) note: all bits clear to logic ?0? at power-on reset, but do not clear after warm reset conditions (non- power-on reset) table 114. output macrocell mcellbc (address = csiop + offset 21h) note: all bits clear to logic ?0? at power-on reset, but do not clear after warm reset conditions (non- power-on reset) mcellbc2 port b or c2 4 5 d2 mcellbc3 port b3 or c3 4 5 d3 mcellbc4 port b4 or c4 4 6 d4 mcellbc5 port b5 4 6 d5 mcellbc6 port b6 4 6 d6 mcellbc7 port b7 orc7 4 6 d7 omc port assignment (1,2) native product terms from and- or array maximum borrowed product terms data bit on 8032 data bus for loading or reading omc bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mcellab7 mcellab6 mcellab5 mcellab4 mcellab3 mcellab2 mcellab1 mcellab0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mcellbc7 mcellbc6 mcellbc5 mcellbc4 mcellbc3 mcellbc2 mcellbc1 mcellbc0
upsd34xx psd module 223/293 28.5.32 omc mask registers there is one omc mask register for each of the two groups of eight omcs shown in table 115 and table 116 . the omc mask registers are used to block loading of data to individual omcs. the default value for the mask registers is 00h, which allows loading of all omcs. when a given bit in a mask register is set to a '1,' the 8032 is blocked from writing to the associated omc flip-flop. for example, suppose that only four of eight omcs (mcellab0-3) are being used for a state machine. the user may not want the 8032 to write to all the omcs in mcellab because it would overwrite the state machine registers. therefore, the user would want to load the mask register for mcellab with the value 0fh before writing omcs. table 115. output macrocell mcellab mask register (address = csiop + offset 22h) note: 1 default is 00h after any reset condition 2 1 = block writing to individual macrocell, 0 = allow writing to individual macrocell table 116. output macrocell mcellbc mask register (address = csiop + offset 23h) note: 1 default is 00h after any reset condition 2 1 = block writing to individual macrocell, 0 = allow writing to individual macrocell 28.5.33 input macrocells the gpld has 20 imcs, one for each pin on port a (80-pin device only), one for each pin on port b, and for the four pins on port c that are not jtag pins. the architecture of one individual imc is shown in figure 79 on page 224 . imcs are individually configurable, and they can strobe a signal coming in from a port pin as a latch (gated), or as a register (clocked), or the imc can pass the signal without strobing, all prior to driving the signal onto the pld input bus. strobing is useful for sampling and debouncing inputs (keypad inputs, etc.) before entering the pld and-or arrays. the outputs of imcs can be read by the 8032 asynchronously when the 8032 reads the csiop registers shown in ta bl e 1 1 7 , ta b l e 1 1 8 , and table 119 on page 224 . it is possible to read a psd module port pin using one of two different methods, one method is by reading imcs as described here, the other method is using mcu i/o mode describ ed in a later section. the optional imc clocking or gating signal us ed to strobe pin inputs is driven by a product term from the and-or array. there is one clocking or gating product term available for each group of four imcs. port inputs 0-3 are controlled by one product term and 4-7 by another. to specify in psdsoft express th e method in which a signal will be strobed as it enters an imc for a given input pin on port a, b, or c, just specify ?pt clocked register? to use a rising edge to clock the incoming signal, or specify ?p t clock latch? to use an active high gate signal to latch the incoming signal. then define an equation for the imc clock (.ld) or the imc gate (.le) signal in the ?i/o equations? section. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mask mcellab7 mask mcellab6 mask mcellab5 mask mcellab4 mask mcellab3 mask mcellab2 mask mcellab1 mask mcellab0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mask mcellbc7 mask mcellbc6 mask mcellbc5 mask mcellbc4 mask mcellbc3 mask mcellbc2 mask mcellbc1 mask mcellbc0
psd module upsd34xx 224/293 if the user would like to latch an incoming signal using the gate signal ale from the 8032, then in psdsoft express, for a given input pin on port a, b, or c, specify ?latched address? as the pin function. if it is desired to pass an incoming signal through an imc directly to the and-or array inputs without clocking or gating (this is mo st common), in psdsoft ex press simply specify ?logic or address? for the input pin function on port a, b, or c. figure 79. detail of a single imc table 117. input macrocell port a (1) (address = csiop + offset 0ah) note: 1 port a not available on 52-pin upsd34xx devices 2 1 = current state of imc is logic '1,' 0 = current state is logic ?0? table 118. input macrocell port b (address = csiop + offset 0bh) note: 1 = current state of imc is logi c '1,' 0 = current state is logic ?0? table 119. input macrocell port c (address = csiop + offset 18h) note: 1 x = not guaranteed value, can be read either '1' or '0.' these are jtag pins. 2 1 = current state of imc is logic '1,' 0 = current state is logic ?0? bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 i m c pa 7 i m c pa 6 i m c pa 5 i m c pa 4 i m c pa 3 i m c pa 2 i m c pa 1 i m c pa 0 input macrocell (imc) d q g d q m u x m u x psdsoft 8032 data bit 8032 read of particular csiop imc register pt clock or gate (.ld or .le) pin input latched input gated input (.ld) (.le) ale psdsoft ale 8032 addr, data, cntl bus from i/o port logic input signal from pin on port a, b, or c from and-or array to pld input bus this sigal is ganged to 3 other imcs, grouping imc 0 - 3 or imc 4 - 7. ai06603a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 imc pb7 imc pb6 imc pb5 imc pb4 imc pb3 imc pb2 imc pb1 imc pb0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 imc pc7 x x imc pc4 imc pc3 imc pc2 x x
upsd34xx psd module 225/293 28.5.34 i/o ports there are four programmable i/o ports on the psd module: port a (80-pin device only), port b, port c, and port d. ports a and b are eight bits each, port c is four bits, and port d is two bits for 80-pin devices or 1-bit for 52-pin devices. each port pin is individually configurable, thus allowing multiple functions per port. the ports are configured using psdsoft express then programming with jtag, and also by the 8032 writing to csiop registers at run-time. topics discussed in this section are: general port architecture port operating modes individual port structure 28.5.35 general port architecture the general architecture for a single i/o port pin is shown in figure 80 on page 226 . port structures for ports a, b, c, and d differ slightly and are shown in figure 85 on page 237 though figure 88 on page 241 . figure 80 on page 226 shows four csiop registers whose outputs are determined by the value that the 8032 writes to csiop direction, drive, control, and data out. the i/o port logic contains an output mux whose mux select signal is determined by psdsoft express and the csiop control register bits at run-time. inputs to this output mux include the following: 1. data from the csiop data out register for mcu i/o output mode (all ports) 2. latched de-multiplexed 8032 address for address output mode (ports a and b only) 3. peripheral i/o mode data bit (port a only) 4. gpld omc output (ports a, b, and c). the port data buffer (pdb) provides feedback to the 8032 and allows only one source at a time to be read when the 8032 reads various csiop registers. there is one pdb for each port pin enabling the 8032 to read the following on a pin-by-pin basis: 1. mcu i/o signal direction setting (csiop direction reg) 2. pin drive type setting (csiop drive select reg) 3. latched addr out mode setting (csiop control reg) 4. mcu i/o pin output setting (csiop data out reg) 5. output enable of pin driver (csiop enable out reg) 6. mcu i/o pin input (csiop data in reg) a port pin?s output enable signal is controlled by a two input or gate whose inputs come from: a product term of the and-or array; the output of the csiop direction register. if an output enable from the and-or array is not defined, and the port pin is not defined as an omc output, and if peripheral i/o mode is not used, then the csiop direction register has sole control of the oe signal. as shown in figure 80 on page 226 , a physical port pin is connected to the i/o port logic and is also separately routed to an imc, allowing the 8032 to read a port pin by two different methods (mcu i/o input mode or read the imc). 28.5.36 port operating modes i/o port logic has several modes of operation. table 115 on page 223 summarizes which modes are available on each port. each of the port operating modes are described in
psd module upsd34xx 226/293 following sections. some operating modes can be defined using psdsoft express, and some by the 8032 writing to the csiop registers at run-time, and some require both. for example, pld i/o, latched address out, and peripheral i/o modes must be defined in psdsoft express and programmed into the device using jtag, but an additional step must happen at run-time to activate latched address out mode and peripheral i/o mode, but not needed for pld i/o. in another example, mcu i/o mode is controlled completely by the 8032 at run-time and only a simple pin name declaration is needed in psdsoft express for documentation. table 116 on page 223 summarizes what actions are needed in psdsoft express and what actions are required by the 8032 at run-time to achieve the various port functions. figure 80. detail of a single i/o port (typical of ports a, b, c) table 120. port operating modes port operating mode port a (80-pin only) port b port c port d find it m c u i / o ye s ye s ye s ye s mcu i/o mode on page 228 pld i/o omc mcellab outputs omc mcellbc outputs external chip-select outputs pld inputs ye s no no ye s ye s ye s no ye s no ye s (1) no ye s no no ye s ye s pld i/o mode on page 230 i/o port logic o u t p u t m u x p d b m u x direction drive select control data out (mcui/o) enable out data in (mcui/o) d bit, periph i/o mode, port a pt output enable (.oe) latched addr bit, port a or b oe mux 8032 data bit output driver typical pin port a, b, c psd module reset one of 6 csiop registers output select peripheral i/o mode sets direction (port a only) 8032 address, data, control bus 1 2 3 4 1 2 3 4 5 6 from omc output to imc from pld input bus from and-or array from omc allocator d clr direction drive control (mcui/o) data out reset psdsoft pselx periph i/o data bit csiop regis- ters q q q q drive type 8032 data bits input buffer output enable wr rd pio en 8032 wr 8032 rd ai07873a
upsd34xx psd module 227/293 note: 1 mcellbc outputs available only on pins pc2, pc3, pc4, and pc7. 2 jtag pins (pc0/tms, pc1/tck, pc5/tdi, pc6/ tdo) are dedicated to jtag pin functions (cannot be used for general i/o). table 121. port configuration setting requirements latched address output yes yes no no latched address output mode on page 232 peripheral i/o mode yes no no no peripheral i/o mode on page 233 jtag isp no no yes (2) no jtag isp mode on page 234 port operating mode port a (80-pin only) port b port c port d find it port operating mode required action in psdsoft express to configure each pin value that 8032 writes to csiop control register at run-time value that 8032 writes to csiop direction register at run- time value that 8032 writes to bit 7 (pio_en) of csiop vm register at run-time mcu i/o choose the mcu i/o function and declare the pin name logic '0' (default) logic 1 = out of upsd logic 0 = into upsd n/a pld i/o choose the pld function type, declare pin name, and specify logic equation(s) n/a direction register has no effect on a pin if pin is driven from omc output n/a latched address output choose latched address out function, declare pin name logic '1' logic '1' only n/a peripheral i/o choose peripheral i/o mode function and specify address range in dpld for pselx n/a n/a pio_en bit = logic 1 (default is '0') 4-pin jtag isp no action required in psdsoft to get 4-pin jtag. by default tdo, tdi, tck, tms are dedicated jtag functions. n/a n/a n/a 6-pin jtag isp (faster programming) choose jtag tstat function for pin pc3 and jtag terr function for pin pc4. n/a n/a n/a
psd module upsd34xx 228/293 28.5.37 mcu i/o mode in mcu i/o mode, the 8032 on the mcu module expands its own i/o by using the i/o ports on the psd module. the 8032 can read psd module i/o pins, set the direction of the i/o pins, and change the output state of i/o pins by accessing the data in, direction, and data out csiop registers respectively at run-time. to implement mcu i/o mode, each desired pin is specified in psdsoft express as mcu i/o function and given a pin name. then 8032 firmware is written to set the direction bit for each corresponding pin during initialization routines (0 = in, 1 = out of the chip), then the 8032 firmware simply reads the corresponding data in register to determine the state of an i/o pin, or writes to a data out register to set the state of a pin. the direction of each pin may be changed dynamically by the 8032 if desired. a mixture of input and output pins within a single port is allowed. figure 80 on page 226 shows the data in, data out, and direction signal paths. the data in registers are defined in ta b l e 1 2 2 to ta bl e 1 2 5 . the data out registers are defined in ta bl e 1 2 6 to table 129 on page 229 . the direction registers are defined in table 130 to table 133 on page 230 . table 122. mcu i/o mode port a data in register (1) (address = csiop + offset 00h) note: 1 port a not available on 52-pin upsd34xx devices 2 for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? table 123. mcu i/o mode port b data in register (address = csiop + offset 01h) note: for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? table 124. mcu i/o mode port c data in register (address = csiop + offset 10h) note: 1 x = not guaranteed value, can be read either '1' or '0.' 2 for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? table 125. mcu i/o mode port d data in register (address = csiop + offset 11h) note: 1 x = not guaranteed value, can be read either '1' or '0.' 2 for each bit, 1 = current state of input pin is logic '1,' 0 = current state is logic ?0? 3 not available on 52-pin upsd34xx devices bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 pc7 x x pc4 pc3 pc2 x x bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 xxxxxpd2 (3) pd1 x
upsd34xx psd module 229/293 table 126. mcu i/o mode port a data out register (1) (address = csiop + offset 04h) note: 1 port a not available on 52-pin upsd34xx devices 2 for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 3 default state of register is 00h after reset or power-up table 127. mcu i/o mode port b data out register (address = csiop + offset 05h) note: 1 for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 2 default state of register is 00h after reset or power-up table 128. mcu i/o mode port c data out register (address = csiop + offset 12h) note: 1 for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 2 default state of register is 00h after reset or power-up table 129. mcu i/o mode port d data out register (address = csiop + offset 13h) note: 1 for each bit, 1 = drive port pin to logic '1,' 0 = drive port pin to logic ?0? 2 default state for register is 00h after reset or power-up 3 not available on 52-pin upsd34xx devices table 130. mcu i/o mode port a direction register (1) (address = csiop + offset 06h) note: 1 port a not available on 52-pin upsd34xx devices 2 for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 3 default state for register is 00h after reset or power-up table 131. mcu i/o mode port b direction in register (address = csiop + offset 07h) note: 1 for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 2 default state for register is 00h after reset or power-up bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 n/a n/a pc4 pc3 pc2 n/a n/a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 (3) pd1 n/a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0
psd module upsd34xx 230/293 table 132. mcu i/o mode port c direction register (address = csiop + offset 14h) note: 1 for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 2 default state for register is 00h after reset or power-up table 133. mcu i/o mode port d direction register (address = csiop + offset 15h) note: 1 for each bit, 1 = out from upsd34xx port pin1, 0 = in to psd34xx port pin 2 default state for register is 00h after reset or power-up 3 not available on 52-pin upsd34xx devices 28.5.38 pld i/o mode pins on ports a, b, c, and d can serve as inputs to either the dpld or the gpld. inputs to these plds from ports a, b, and c are routed through imcs before reaching the pld input bus. inputs to the plds from port d do not pass through imcs, but route directly to the pld input bus. pins on ports a, b, and c can serve as outputs from gpld omcs, and port d pins can be outputs from the dpld (external chip-selects) which do not consume omcs. whenever a pin is specified to be a pld output, it cannot be used for mcu i/o mode, or other pin modes. if a pin is specified to be a pld input, it is still possible to read the pin using mcu i/o input mode with the csiop register data in. also, the csiop direction register can still affect a pin which is used for a pld input. the csiop data out register has no effect on a pld output pin. each pin on ports a, b, c, and d have a tri-state buffer at the final output stage. the output enable signal for this buffer is driven by the logical or of two signals. one signal is an output enable signal generated by the and-or array (from an .oe equation specified in psdsoft), and the other signal is the output of the csiop direction register. this logic is shown in figure 80 on page 226 . at power-on, all port pins default to high-impedance input (direction registers default to 00h). however, if an equation is written for the output enable that is active at power-on, then the pin will behave as an output. pld i/o equations are specified in psdsoft express and programmed into the upsd using jtag. figure 81 shows a very simple combinatorial logic example which is implemented on pins of port b. to give a general idea of how pld logi c is implemented using psdsoft express, figure 82 on page 231 illustrates the pin declaration window of psdsoft express, showing the pld output at pin pb0 declared as ?combinatorial ? in the ?pld output? section, and a signal name, ?pld_out?, is specified. the other three signals on pins pb1, pb2, and pb3 would be declared as ?logic or address? in the ?pld input? section, and given signal names. in the ?design assistant? window of psdsoft express shown in figure 83 on page 232 , the user simply enters the logic equation for the si gnal ?pld_out? as shown. the user can either type in the logic statements or enter them using a point-and-click method, selecting various signal names and logic operators available in the window. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 n/a n/a pc4 pc3 pc2 n/a n/a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 (3) pd1 n/a
upsd34xx psd module 231/293 after psdsoft express has accepted and realized the logic from the equations, it synthesizes the logic statement: pld_out = ( pld_in_1 # pld_in_2 ) & !pld_in_3; to be programmed into the gpld. see the psdsoft user?s manual for all the steps. note: if a particular omc output is specified as an internal node and not specified as a port pin output in psdsoft express, then the port pin that is associated with that omc can be used for other i/o functions. figure 81. simple pld logic example figure 82. pin declarations in psdsoft express for simple pld example pldin 1 pldin 2 pldin 3 pld out pb0 pb3 pb2 pb1 ai09178
psd module upsd34xx 232/293 figure 83. using the design assistant in psdsoft express for simple pld example 28.5.39 latched address output mode in the mcu module, the data bus bits d0-d15 are multiplexed with the address bits a0-a15, and the ale signal is used to separate them with respect to time. sometimes it is necessary to send de-multiplexed address signals to external peripherals or memory devices. latched address output mode will drive individual demuxed address signals on pins of ports a or b. port pins can be designated for this function on a pin-by-pin basis, meaning that an entire port will not be sacrificed if only a few address signals are needed. to activate this mode, the desired pins on po rt a or port b are designated as ?latched address out? in psdsoft. then in the 8032 initia lization firmware, a logic ?1? is written to the csiop control register for port a or port b in each bit position that corresponds to the pin of the port driving an address signal. ta b l e 1 3 4 and table 135 define the csiop control register locations and bit assignments. the latched low address byte a4-a7 is available on both port a and port b. the high address byte a8-a15 is available on port b only. selection of high or low address byte is specified in psdsoft express. table 134. latched address output, port a contro register (1) (address = csiop + offset 02h)l note: 1 port a not available on 52-pin upsd34xx devices 2 for each bit, 1 = drive demuxed 8032 address signal on pin, 0 = pin is default mode, mcu i/o 3 default state for register is 00h after reset or power-up bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 (addr a7) pa 6 (addr a6) pa 5 (addr a5) pa 4 (addr a4) pa 3 (addr a3) pa 2 (addr a2) pa 1 (addr a1) pa 0 (addr a0)
upsd34xx psd module 233/293 table 135. latched address output, port b contro register (address = csiop + offset 03h)l note: 1 for each bit, 1 = drive demuxed 8032 address signal on pin, 0 = pin is default mode, mcu i/o 2 default state for register is 00h after reset or power-up 28.5.40 peripheral i/o mode this mode will provide a data bus repeater func tion for the 8032 to interface with external parallel peripherals. the mode is only available on port a (80-pin devices only) and the data bus signals, d0 - d7, are de-multiplexed (no address a0-a7). when active, this mode behaves like a bidirectional buffer, with the direction automatically controlled by the 8032 rd and wr signals for a specified address r ange. the dpld signals psel0 and psel1 determine this address range. figure 80 on page 226 shows the action of peripheral i/o mode on the output enable logic of the tri-state output driver for a single port pin. figure 84 on page 233 illustrates data repeater th e operation. to activate th is mode, choose the pin function ?peripheral i/o mode? in psdsoft express on any port a pin (all eight pins of port a will automatically change to this mode). next in psdsoft, spec ify an address range for the pselx signals in the ?chip-select? section of the ?design assistant?. the user can specify an address range for either psel0 or psel 1. always qualify the pselx equation with ?psen is logic '1'? to ensure peripheral i/o mode is only active during 8032 data cycles, not code cycles. only one equat ion is needed since pselx si gnals are or?ed together ( figure 84 ). then in the 8032 initializ ation firmware, a logic ?1? is written to the csiop vm register, bit 7 (pio_en) as shown in table 99 on page 184 . after this, port a will automatically perform this repeater function whenever the 8032 presents an address (and memory page number, if paging is used) that is within the ra nge specified by pselx. once port a is designated as peripheral i/o mode in psdsoft express, it cannot be used for other functions. note: the user can alternatively connect an external parallel peripheral to the standard 8032 ad0- ad7 pins on an 80-pin upsd device (not port a), but these pins have multiplexed address and data signals, with a we aker fanout drive capability. figure 84. peripheral i/o mode bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 (addr a7 or a15) pb6 (addr a6 or a14) pb5 (addr a5 or a13) pb4 (addr a4 or a12) pb3 (addr a3 or a11) pb2 (addr a2 or a10) pb1 (addr a1 or a9) pb0 (addr a0 or a8) psel1 port a pins pa0 - pa7 psel0 vm register bit 7 (pio en) 8032 rd 8032 wr 8032 data bus d0-d7 (de-muxed) 8 8 ai02886a
psd module upsd34xx 234/293 28.5.41 jtag isp mode four of the pins on port c are based on th e ieee 1149.1 jtag specif ication and are used for in-system programming (isp) of the psd module and debugging of the 8032 mcu module. these pins (tdi, tdo, tms, tck) are dedicated to jtag and cannot be used for any other i/o function. there are two optional pins on port c (tstat and terr ) that can be used to reduce programming time during isp. see section 28.6.1: jtag isp and jtag debug on page 251 . 28.5.42 other port capabilities it is possible to change the type of output drive on the ports at run-time. it is also possible to read the state of the output enable signal of the output driver at run-time. the following sections provide the details. 28.5.43 port pin drive options the csiop drive select registers allow reconfiguration of the output drive type for certain pins on ports a, b, c, and d. the 8032 can change the default drive type setting at run-time. the is no action needed in psdsoft express to change or define these pin output drive types. figure 80 on page 226 shows the csiop drive select register output controlling the pin output driver. the default setting for drive type for all pins on ports a, b, c, and d is a standard cmos push-pull output driver. note: when a pin on port a, b, c, d is not used as an output and has no external device driving it as an input (floating pin), excess power consumption can be avoided by placing a weak pull- up resistor (100k ? ) to v dd which keeps the cmos input pin from floating. 28.5.44 drive select registers the csiop drive select registers will configure a pin output driver as open drain or cmos push/pull for some port pins, and controls the slew rate for other port pins. an external pull- up resistor should be used for pins configured as open drain, and the resistor should be sized not to exceed the current si nk capability of the pin (see dc specifications). open drain outputs are diode clamped, thus the maximum voltage on an pin configured as open drain is v dd + 0.7v. a pin can be configured as open drain if its corresponding bit in the drive select register is set to logic '1.' note: the slew rate is a measurement of the rise and fall times of an output. a higher slew rate means a faster output response and may create more electrical noise. a pin operates in a high slew rate when the corresponding bit in the drive register is set to '1.' the default rate is standard slew rate (see ac specifications). table 136 through table 139 on page 235 show the csiop drive registers for ports a, b, c, and d. the tables summarize which pins can be configured as open drain outputs and which pins the slew rate can be changed. the default output type is cmos push/pull output with normal slew rate. 28.5.45 enable out registers the state of the output enable signal for the output driver at each pin on ports a, b, c, and d can be read at any time by the 8032 when it reads the csiop enable output registers. logic '1' means the driver is in output mode, logic ?0? means the output driver is in high-impedance
upsd34xx psd module 235/293 mode, making the pin suitable for input mode (read by the input buffer shown in figure 80 on page 226 ). figure 80 shows the three sources that can control the pin output enable signal: a product term from and-or array; the csiop direction register; or the peripheral i/o mode logic (port a only). the csiop enable out registers represent the state of the final output enable signal for each port pin driver, and are defined in table 140 on page 236 through table 143 on page 236 . table 136. port a pin drive select register (1) (address = csiop + offset 08h) note: 1 port a not available on 52-pin upsd34xx devices 2 for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 3 default state for register is 00h after reset or power-up table 137. port b pin drive select register (address = csiop + offset 09h) note: 1 for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 2 default state for register is 00h after reset or power-up table 138. port c pin drive select register (address = csiop + offset 16h) note: 1 for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 2 default state for register is 00h after reset or power-up table 139. port d pin drive select register (address = csiop + offset 17h) note: 1 for each bit, 1 = pin drive type is selected, 0 = pin drive type is default mode, cmos push/pull 2 default state for register is 00h after reset or power-up 3 pin is not available on 52-pin upsd34xx devices bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 open drain pa 6 open drain pa 5 open drain pa 4 open drain pa 3 slew rate pa 2 slew rate pa 1 slew rate pa 0 slew rate bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 open drain pb6 open drain pb5 open drain pb4 open drain pb3 slew rate pb2 slew rate pb1 slew rate pb0 slew rate bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 open drain n/a (jtag) n/a (jtag) pc4 open drain pc3 open drain pc2 open drain n/a (jtag) n/a (jtag) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 (3) slew rate pd1 slew rate n/a
psd module upsd34xx 236/293 table 140. port a enable out register (1) (address = csiop + offset 0ch) note: 1 port a not available on 52-pin upsd34xx devices 2 for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) table 141. port b enable out register (address = csiop + offset 0dh) note: for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) table 142. port c enable out register (address = csiop + offset 1ah) note: 1 for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) table 143. port d enable out register (address = csiop + offset 1bh) note: 1 for each bit, 1 = pin drive is enabled as an output, 0 = pin drive is off (high-impedance, pin used as input) 2 pin is not available on 52-pin upsd34xx devices 28.5.46 individual port structures ports a, b, c, and d have some differences. the structure of each individual port is described in the next sections. 28.5.47 port a structure port a supports the following operating modes: mcu i/o mode gpld output mode from output macrocells mcellabx gpld input mode to input macrocells imcax latched address output mode peripheral i/o mode port a also supports open drain/slew rate output drive type options using csiop drive select registers. pins pa0-pa3 can be configured to fast slew rate, pins pa4-pa7 can be configured to open drain mode. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pa 7 o e pa 6 o e pa 5 o e pa 4 o e pa 3 o e pa 2 o e pa 1 o e pa 0 o e bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pb7 oe pb6 oe pb5 oe pb4 oe pb3 oe pb2 oe pb1 oe pb0 oe bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc7 oe n/a (jtag) n/a (jtag) pc4 oe pc3 oe pc2 oe n/a (jtag) n/a (jtag) bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n/a n/a n/a n/a n/a pd2 oe (2) pd1 oe n/a
upsd34xx psd module 237/293 see figure 85 for details. figure 85. port a structure note: 1 port pins pa0-pa3 are capable of fast slew rate output drive option. port pins pa4-pa7 are capable of open drain output option. 28.5.48 port b structure port b supports the following operating modes: mcu i/o mode gpld output mode from output macr ocells mcellabx, or mcellbcx (omc allocator routes these signals) gpld input mode to input macrocells imcbx latched address output mode port b also supports open drain/slew rate output drive type options using the csiop drive select registers. pins pb0-pb3 can be configured to fast slew rate, pins pb4-pb7 can be configured to open drain mode. see figure 86 for detail. i/o port a logic o u t p u t m u x p d b m u x direction drive select control data out (mcui/o) enable out data in (mcui/o) d bit, periph i/o mode pt output enable (.oe) latched addr bit oe mux output enable typical pin, port a psd module reset one of 6 csiop registers output select peripheral i/o mode sets direction 8032 address, data, control bus 1 2 3 4 1 2 3 4 5 6 from omc output (mcellabx) from pld input bus from and- or array from omc allocator d clr direction drive control (mcui/o) data out 8032 wr reset psdsoft 8032 rd pselx wr rd periph i/o data bit to imcs pio en csiop regis- ters q q q q drive type select (1) 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd pin output 1 = open drain, pa4 - pa7 1 = fast slew rate, pa0 - pa3 imca0 - imca7 ai09179
psd module upsd34xx 238/293 figure 86. port b structure note: 1 port pins pb0-pb3 are capable of fast slew rate output drive option. port pins pb4-pb7 are capable of open drain output option. 28.5.49 port c structure port c supports the following operating modes on pins pc2, pc3, pc4, pc7: mcu i/o mode gpld output mode from output macr ocells mcellbc2, mc ellbc3, mcellbc4, mcellbc7 gpld input mode to input macrocells imcc2, imcc3, imcc4, imcc7 see figure 87 on page 239 for detail. port c pins can also be configured in psdsoft for other dedicated functions: pins pc3 and pc4 support tstat and terr status indicators, to reduce the amount of time required for jtag isp programming. these two pins must be used together for this function, adding to the four standard jtag signals. when tstat and terr are used, it is referred to as ?6-pin jtag?. pc3 and pc4 cannot be used for other functions i/o port b logic o u t p u t m u x p d b m u x direction drive select control data out (mcui/o) enable out data in (mcui/o) pt output enable (.oe) latched addr bit output enable output enable typical pin, port b psd module reset one of 6 csiop registers output select 8032 address, data, control bus 1 2 3 1 2 3 4 5 6 from omc output (mcellabx or mcellbcx) from pld input bus from and- or array from omc allocator d clr direction drive control (mcui/o) data out 8032 wr reset psdsoft 8032 rd to imcs csiop regis- ters q q q q drive type select (1) 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd pin output 1 = open drain, pb4 - pb7 1 = fast slew rate, pb0 - pb3 imcb0 - imcb7 ai09180
upsd34xx psd module 239/293 if they are used for 6-pin jtag. see section 28.6.1: jtag isp and jtag debug on page 251 for details. ? pc2 can be used as a voltage input (from battery or other dc source) to backup the contents of sram when v dd is lost. this function is specified in psdsoft express as section 28.5.62: sram standby mode (battery backup) on page 250 . ? pc3 can be used as an output to indicate when a flash memory program or erase operation has completed. this is specified in psdsoft express as section 28.5.12: ready/busy (pc3) on page 208 . ? pc4 can be used as an output to indicate when the sram has switched to backup voltage (when v dd is less than the battery input voltage on pc2). this is specified in psdsoft express as ?standby-on indicator? (see section 28.5.62: sram standby mode (battery backup) on page 250 ). the remaining four pins (tdi, tdo, tck, tms) on port c are dedicated to the jtag function and cannot be used for any other function. see section 28.6.1: jtag isp and jtag debug on page 251 . port c also supports the open drain output drive type options on pins pc2, pc3, pc4, and pc7 using the csiop drive select registers. figure 87. port c structure note: 1 pull-up switches to v bat when sram goes to battery back-up mode. 2 optional function on a specific port c pin. i/o port c logic o u t p u t m u x p d b m u x direction drive select data out (mcui/o) enable out data in (mcui/o) pt output enable, .oe (jtag state machine automatically controls oe for jtag signals) output enable typical pin, port c psd module reset one of 6 csiop registers 8032 address, data, control bus 1 2 3 4 5 1 2 3 4 5 from omc output (mcellbcx) standby on (2) from sram back-up circuit from flash memories to/from jtag state machine from pld input bus from and- or array from omc allocator d clr direction drive (mcui/o) data out 8032 wr reset psdsoft 8032 rd to imcs csiop regis- ters q q q drive type select (2) 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd /v bat (1) v dd /v bat (1) pin output 50k pull-up only on jtag tdi, tms, tck signals to sram battery back-up circuit (2) imcc2, imcc3, imcc4, imcc7 rdy/bsy (2) tdo, tstat (2) , terr (2) tdi, tms, tck ai09181
psd module upsd34xx 240/293 28.5.50 port d structure port d has two i/o pins (pd1, pd2) on 80-pin upsd34xx devices, and just one pin (pd1) on 52-pin devices, supporting the following operating modes: mcu i/o mode dpld output mode for external chip sele cts, ecs1, ecs2. this does not consume omcs in the gpld. pld input mode ? direct input to the pld input bus available to dpld and gpld. does not use imcs see figure 88 on page 241 for detail. port d pins can also be configured in psdsoft as pins for other dedicated functions: pd1 can be used as a common clock input to all 16 omc flip-flops (see section 28.1.11: omcs on page 189 ) and also the section 28.5.52: automatic power- down (apd) on page 245 . pd2 can be used as a common chip select signal (csi ) for the flash and sram memories on the psd module (see section 28.5.54: chip select input (csi) on page 247 ). if driven to logic ?1? by an external source, csi will force all memories into standby mode regardless of what other internal memory select signals are doing on the psd module. this is specified in psds oft as ?psd chip select input, csi ?. port d also supports the fast slew rate output drive type option using the csiop drive select registers.
upsd34xx psd module 241/293 figure 88. port d structure note: 1 optional function on a specific port d pin. 28.5.51 power management the psd module offers configurable power saving options, and also a way to manage power to the sram (battery backup). these options may be used individually or in combinations. a top level description for these functions is given here, then more detailed descriptions will follow. zero-power memory: all memory arrays (flash and sram) in the psd module are built with zero-power technology, which puts the memories into standby mode (~ zero dc current) when 8032 address signals ar e not changing. as soon as a transition occurs on any address input, the affected memory ?wakes up?, changes and latches its outputs, then goes back to standby. the designer does not have to do anything special i/o port d logic o u t p u t m u x p d b m u x direction drive select data out (mcui/o) enable out data in (mcui/o) pt output enable (.oe) output enable output enable typical pin, port d psd module reset one of 5 csiop registers 8032 address, data, control bus 1 2 1 2 3 4 5 from dpld external chip (ecsx) from pld input bus from and- or array from dpld d clr direction drive (mcui/o) data out 8032 wr reset psdsoft 8032 rd to power management and pld input bus csiop regis- ters q q q drive type select 8032 data bits 8032 data bit pin input cmos buffer no hysteresis v dd v dd pin output 1 = fast slew rate pd1. pin, pd2.pin directly to pld input bus, no imc csi (1) to power management clkin (1) ai09182
psd module upsd34xx 242/293 to achieve this memory standby mode when no inputs are changing?it happens automatically. thus, the slower the 8032 clock, the lower the current consumption. both plds (dpld and gpld) are also zero-power, but this is not the default condition. the 8032 must set a bit in one of the csiop pmmr registers at run-time to achieve zero- power. automatic power-down (apd): the apd feature allows the psd module to reach its lowest current consumption levels. if enabled, the apd counter will ti me-out when there is a lack of 8032 bus activity for an extended amount of time (8032 asleep). after time- out occurs, all 8032 address and data buffers on the psd module are shut down, preventing the psd module memories and potentially the plds from waking up from standby, even if address inputs are changing state because of noise or any external components driving the address lines. since the actual address and data buffers are turned off, current consumption is even further reduced. note: non-address signals are still available to pld inputs and w ill wake up the plds if these signals are changing state, but will not wake up the memories. the apd counter requires a relatively slow external clock input on pin pd1 that does stop when the 8032 goes to sleep mode. forced power-down (fpd): the mcu can put the psd module into power-down mode with the same results as using apd described above, but fpd does not rely on the apd counter. instead, fpd will force the psd module into power-down mode when the mcu firmware sets a bit in one of the csiop pmmr registers. this is a good alternative to apd because no external clock is needed for the apd counter. psd module chip select input (csi ): this input on pin pd2 (80-pin devices only) can be used to disable the internal memories, placing them in standby mode even if address inputs are changing. this feature does not block any internal signals (the address and data buffers are still on but signals are ignored) and csi does not disable the plds. this is a good alternative to using the apd counter, which requires an external clock on pin pd1. non-turbo mode: the plds can operate in turbo or non-turbo modes. turbo mode has the shortest signal propagation delay, but consumes more current than non-turbo mode. a csiop register can be written by the 8032 to select modes, the default mode is with turbo mode enabled. in non-turbo mode, the plds can achieve very low standby current (~ zero dc current) while no pld i nputs are changing, a nd the plds will even use less ac current when inputs do change compared to turbo mode. when the turbo mode is enabled, there is a significant dc current component and the ac current component is higher than non-turbo mode, as shown in figure 96 on page 259 (5v) and figure 97 on page 260 (3.3v). blocking bits: significant power savings can be achieved by blocking 8032 bus control signals (rd , wr , psen , ale) from reaching pld inputs, if these signals are not used in any pld equations. blocking is achieved by the 8032 writing to the ?blocking bits? in csiop pmmr registers. current consumption of the plds is directly related to the composite frequency of all transitions on pld inputs, so blocking certain pld inputs can significantly lower pld operating frequency and power consumption (resulting in a lower frequency on the graphs of figure 96 on page 259 and figure 97 on page 260 ). sram backup voltage: pin pc2 can be configured in psdsoft to accept an alternate dc voltage source (battery) to automatically retain the contents of sram when v dd drops below this alternate voltage. note: it is recommended to prevent unused inputs from floating on po rts a, b, c, and d by pulling them up to v dd with a weak external resistor (100k ? ), or by setting the csiop direction
upsd34xx psd module 243/293 register to ?output? at run-time for all unused inputs. th is will prevent the cmos input buffers of unused input pins from drawing excessive current. the csiop pmmr register definitions are shown in ta b l e 1 4 4 through table 146 on page 244 . table 144. power management mode register pmmr0 (address = csiop + offset b0h) note: all the bits of this register are cleared to zero following power-up. subsequent reset (rst ) pulses do not clear the registers. note: 1 blocking bits should be set to logic ?1? on ly if the signal is not needed in a dpld or gpld logic equation. bit 0 x 0 not used, and should be set to zero. bit 1 apd enable 0 automatic power down (apd) counter is disabled. 1 apd counter is enabled bit 2 x 0 not used, and should be set to zero. bit 3 pld turbo disable 0 = on pld turbo mode is on 1 = off pld turbo mode is off, saving power. bit 4 blocking bit, clkin to plds (1) 0 = on clkin (pin pd1) to the pld input bus is not blocked. every transition of clkin powers-up the plds. 1 = off clkin input to pld input bus is bloc ked, saving power. but clkin still goes to apd counter. bit 5 blocking bit, clkin to omcs only (1) 0 = on clkin input is not blocked from reaching all omcs? common clock inputs. 1 = off clkin input to common clock of all omcs is blocked, saving power. but clkin still goes to apd counter and all pld logic besides the common clock input on omcs. bit 6 x 0 not used, and should be set to zero. bit 7 x 0 not used, and should be set to zero.
psd module upsd34xx 244/293 table 145. power management mode register pmmr2 (address = csiop + offset b4h) note: the bits of this register are cleared to zero following power-up. subsequent reset (rst ) pulses do not clear the registers. note: 1 blocking bits should be set to logic ?1? on ly if the signal is not needed in a dpld or gpld logic equation. table 146. power management mode register pmmr3 (address = csiop + offset c7h) note: the bits of this register are cleared to zero following power-up. subsequent reset (rst ) pulses do not clear the registers. bit 0 x 0 not used, and should be set to zero. bit 1 x 0 not used, and should be set to zero. bit 2 blocking bit, wr to plds (1) 0 = on 8032 wr input to the pld input bus is not blocked. 1 = off 8032 wr input to pld input bus is blocked, saving power. bit 3 blocking bit, rd to plds (1) 0 = on 8032 rd input to the pld input bus is not blocked. 1 = off 8032 rd input to pld input bus is blocked, saving power. bit 4 blocking bit, psen to plds (1) 0 = on 8032 psen input to the pld input bus is not blocked. 1 = off 8032 psen input to pld input bus is blocked, saving power. bit 5 blocking bit, ale to plds (1) 0 = on 8032 ale input to the pld input bus is not blocked. 1 = off 8032 ale input to pld input bus is blocked, saving power. bit 5 blocking bit, pc7 to plds (1) 0 = on pin pc7 input to the pld input bus is not blocked. 1 = off pin pc7 input to pld input bus is blocked, saving power. bit 7 x 0 not used, and should be set to zero. bit 0 x 0 not used, and should be set to zero. bit 1 force_pd 0 = off apd counter will cause power-down mode if apd is enabled. 1 = on power-down mode will be entered immediately regardless of apd activity. bit 3- 7 x 0 not used, and should be set to zero.
upsd34xx psd module 245/293 28.5.52 automatic power-down (apd) the apd unit shown in figure 74 on page 215 puts the psd module into power-down mode by monitoring the activity of the 8032 address latch enable (ale) signal. if the apd unit is enabled by writing a logic ?1? to bit 1 of the cs iop pmmr0 register, and if ale signal activity has stopped (8032 in sleep mode), then the four-bit apd counter starts counting up. if the ale signal remains inactive for 15 clock periods of the clkin signal (pin pd1), then the apd counter will reach maximum count and the po wer down indicator signal (pdn) goes to logic ?1? forcing the psd module into power-down mode. during this time, all buffers on the psd module for 8032 address and data signals are disabled in silicon, preventing the psd module memories from waking up from stand-by mode, even if noise or other devices are driving the address lines. the plds will also st ay in standby mode if the plds are in non- turbo mode and if all other pld inputs (non-address signals) are static. however, if the ale signal has a transition before the apd counter reaches max count, the apd counter is cleared to zero and the p dn signal will not go active, preventing power- down mode. to prevent unwanted apd time-outs during normal 8032 operation (not sleeping), it is important to choose a clock frequency for clkin that will not produce 15 or more pulses within the longest period between ale transitions. a 32768 hz clock signal is quite often an ideal frequency for clkin and apd, and this frequency is often available on external supervisor or real-time clock devices. the ?pdn? power-down indicator signal is ava ilable to the pld input bus to use in any pld equations if desired. the user may want to send this signal as a pld output to an external device to indicate the psd module is in power-down mode. psdsoft express automatically includes the ?pdn? signal in the dpld chip select equations for fsx, csbootx, rs0, and csiop. the following should be kept in mind when the psd module is in power-down mode: 8032 address and data bus signals are blocked from all memories and both plds. the psd module comes out of power-down mode when: ale starts pulsing again, or the csi input on pin pd2 transitions from logic ?1? to logic '0,' or the psd module reset signal, rst , transitions from logic ?0? to logic '1.' various signals can be blocked (prior to power-down mode) from entering the plds by using ?blocking bits? in csiop pmmr registers. all memories enter standby mode, and the state of the plds and i/o ports are unchanged (if no pld inputs change). table 148 on page 251 shows the effects of power-down mode on i/o pins while in various operating modes. the 8032 ports 1,3, and 4 on the mcu module are not affected at all by power-down mode in the psd module. power-down standby current given in the ac specifications for psd module assume there are no transitions on any unblocked pld input, and there are no output pins driving any loads. the apd counter will count whenever bit 1 of csio p pmmr0 register is set to logic '1,' and when the ale signal is steady at either logic ?1? or logic ?0? (not transitioning). figure 90 on page 247 shows the flow leading up to power-down mode. the only action required in psdsoft express to enable apd mode is to select the pin function ?common clock input, clkin? before programming with jtag.
psd module upsd34xx 246/293 28.5.53 forced power-down (fdp) an alternative to apd is fpd. the resulting power-savings is the same, but the pdn signal in figure 89 on page 247 is set and power-down mode is entered immediately when firmware sets the force_pd bit to logic '1' in the csiop register pmmr3 (bit 1). fpd will override apd counter activity when force_pd is set. no external clock source for the apd counter is needed. the force_pd bit is cleared only by a reset condition. caution must be used when implementing fpd because code memory goes off-line as soon as psd module power-down mode is en tered, leaving the m cu with no instruction stream to execute. the mcu module must put itself into power- down mode after it puts the psd module into power-down mode. how can it do this if code memory goes off-line? the answer is the pre- fetch queue (pfq) in the mcu module. by using the instruction scheme shown in the 8051 assembly code example in ta bl e 1 4 7 , the pfq will be loaded with the final instructions to command the mcu module to power down mode after the pds module goes to power- down mode. in this case, even though the code memory goes off-line in the psd module, the last few mcu instruction are sourced from the pfq. table 147. forced power-down example pdown: anl a8h, #7fh ; disable all interrupts orl 9dh, #c0h ; ensure pfq and bc are enabled mov dptr, #xxc7 ; load xdata pointe r to select pmmr3 register (xx = base ; address of csiop registers) clr a ; clear a jmp loop ; first loop - fill pfq/bq with power down instructions nop ; second loop - fetch code from pfq/bc and set power- ; down bits for psd module and then mcu module loop: movx @dptr, a ; set force_pd bit in pmmr3 in psd module in second ; loop mov 87h, a ; set pd bit in pcon register in mcu module in second ; loop mov a, #02h ; set power-down bit in the a register, but not in pmmr3 or ; pcon yet in first loop jmp loop ; upsd enters into power-down mode in second loop
upsd34xx psd module 247/293 figure 89. automatic power-down (apd) unit figure 90. power-down mode flow chart 28.5.54 chip select input (csi ) pin pd2 of port d can optionally be configured in psdsoft express as the psd module chip select input, csi , which is an active-low logic input. by default, pin pd2 does not have the csi function. when the csi function is specified in psdsoft express, the csi signal is automatically included in dpld chip select equations for fsx, csbootx, rs0, and csiop. when the csi pin is driven to logic ?0? from an external device, all of these memories will be available for pmmr0, bit 1 (apd en) 8032 ale psd module rst_ csi (pin pd2) clkin (pin pd1) pdn omc outputs fsx csbootx rs0 csiop 8032 data from mcu module 8032 addr from mcu module pdn pdn csi pmmr3, bit 1 (force_pd) enable 1 = found transition 1 = found edge clear full count dpld chip select equations gpld transition detection edge detection 4-bit apd up-counter enable clk 1 = power down mode enable psd module line buffers 8032 data 8032 addr when csi function is specified in psdsoft express, csi is part of equations for fsx, csbootx, rs0, and csiop ai06608b enable apd. set pmmr0, bit 1 = 1 reset optional . disable desired inputs to plds by setting pmmr0 bits 4 and 5, and pmmr2 bits 2 through 6 ale idle for 15 clkin clocks? pdn = 1, psd module in power- down mode yes no ai09183
psd module upsd34xx 248/293 read and write operations. when csi is driven to logic '1,' none of these memories are available for selection, regardless of the address activity from the 8032, reducing power consumption. the state of the pld and port i/o pins are not changed when csi goes to logic ?1? (disabled). 28.5.55 pld non-turbo mode the power consumption and speed of the plds are controlled by the turbo bit (bit 3) in the csiop pmmr0 register. by setting this bit to logic '1,' the turbo mode is turned off and both plds consume only stand-by current when all pld inputs have no transitions for an extended time (65ns for 5v devices, 100ns for 3.3 v devices), significantly reducing current consumption. the plds will latch their outputs and go to standby, drawing very little current. when turbo mode is off, pld propagation delay time is increased as shown in the ac specifications for the psd module. since this additional propagation delay also effects the dpld, the response time of the memories on the psd module is also lengthened by that same amount of time. if turbo mode is off, the user should add an additional wait state to the 8032 buscon sfr register if the 8032 clock frequency is higher that a particular value. please refer to table 38 on page 82 in the mcu module section. the default state of the turbo bit is logic '0,' meaning turbo mode is on by default (after power-up and reset conditions) until it is turned off by the 8032 writing to pmmr0. 28.5.56 pld current consumption figure 96 on page 259 and figure 97 on page 260 (5v and 3.3v devices respectively) show the relationship between pld current consumption and the composite frequency of all the transitions on pld inputs, indicating that a higher input frequency results in higher current consumption. current consumption of the plds have a dc component and an ac component. both need to be considered when calculating current consumption for a specific pld design. when turbo mode is on, there is a linear relationship between current and frequency, and there is a substantial dc current component consumed by the psd module when there are no transitions on pld inputs (composite frequency is zero). the magnitude of this dc current component is directly proportional to how many product terms are used in the equations of both plds. psdsoft express generates a ?fitter? report that specifies how many product terms were used in a design out of a total of 186 available product terms. figure 96 on page 259 and figure 97 on page 260 both give two examples, one with 100% of the 186 product terms used, and another with 25% of the 186 product terms used. 28.5.57 turbo mode current consumption to determine the ac current component of the specific pld design with turbo mode on, the user will have to interpolate from the graph, given the number of product terms specified in the fitter report, and the estimated composite frequency of pld input signal transitions. for the dc component (y-axis crossing), the user can calculate the number by multiplying the number of product terms used (from fitter report) times the dc current per product term specified in the dc specifications for the psd module. the total pld current usage is the sum of its ac and dc components. 28.5.58 non-turbo m ode current consumption notice in figure 96 on page 259 and figure 97 on page 260 that when turbo mode is off, the dc current consumption is ?zero? (just st andby current) when the composite frequency
upsd34xx psd module 249/293 of pld input transitions is zero (no input transitions). now moving up the frequency axis to consider the ac current component, current consumption remains considerably less than turbo mode until pld input transitions happen so rapidly that the plds do not have time to latch their outputs and go to standby between the transitions anymore. this is where the lines converge on the graphs, and current consumption becomes the same for pld input transitions at this frequency and higher regardless if turbo mode is on or off. to determine the current consumption of the plds with turbo mode off, extrapolate the ac component from the graph based on number of product terms and input frequency. the only dc component in non-turbo mode is the psd module standby current. the key to reducing pld current consumption is to reduce the composite frequency of transitions on the pld input bus, moving down the frequency scale on the graphs. one way to do this is to carefully select which sign als are entering pld inputs, not selecting high frequency signals if they are not used in pld equations. another way is to use pld ?blocking bits? to block certain signals from entering the pld input bus. 28.5.59 pld blocking bits blocking specific signals from entering the plds using bits of the csiop pmmr registers can further reduce pld ac current consumption by lowering the effective composite frequency of inputs to the plds. 28.5.60 blocking 8032 bus control signals when the 8032 is active on the mcu module, four bus control signals (rd , wr , psen , and ale) are constantly transitioning to manage 8032 bus traffic. each time one of these signals has a transition from logic ?1? to '0,' or 0 to '1,' it will wake up the plds if operating in non- turbo mode, or when in turbo mode it will cause the affected pld gates to draw current. if equations in the dpld or gpld do not use the signals rd , wr , psen , or ale then these signals can be blocked which will reduce the ac current component substantially. these bus control signals are rarely used in dpld equations because th ey are routed in silicon directly to the memory arrays of the psd module, bypassing the plds. for example, it is not necessary to qualify a memory chip select signa l with an mcu write strobe, such as ?fs0 = address range & !wr_?. only ?fs0 = address range? is needed. each of the 8032 bus control signals may be blocked individually by writing to bits 2, 3, 4, and 5 of the pmmr2 register shown in table 145 on page 244 . blocking any of these four bus control signals only preven ts them from reaching the plds, but they will always go to the memories directly. however, sometimes it is necessary to use these 8032 bus control signals in the gpld when creating interface signals to external i/o peripherals. but it is still possible to save power by dynamically unblocking the bus signals before reading/writing the external device, then blocking the signals after the communication is complete. the user can also block an input signal coming from pin pc7 to the pld input bus if desired by writing to bit 6 of pmmr2. 28.5.61 blocking common clock, clkin the input clkin (from pin pd1) can be blocked to reduce current consumption. clkin is used as a common clock input to all omc flip-flips, it is a gene ral input to the pld input bus, and it is used to clock the apd counter. in psdsoft express, the function of pin pd1 must be
psd module upsd34xx 250/293 specified as ?common clock input, clkin? before programming the device with jtag to get the clkin function. bit 4 of pmmr0 can be set to logic ?1? to block clkin from reaching the pld input bus, but clkin will still reach the apd counter. bit 5 of pmmr0 can be set to logic ?1? to block clkin from reaching the omc flip-flops only, but clkin is still available to the pld input bus and the apd counter. see table 144 on page 243 for details. 28.5.62 sram standby mode (battery backup) the sram on the psd module may optionally be backed up by an external battery (or other dc source) to make its contents non-volatile. this is achieved by connecting a battery to pin pc2 on port c and selecting the ?sram standby? function for pin pc2 within psdsoft express. automatic voltage supply cross-over circ uitry is built into the psd module to switch sram supply to battery as soon as v dd drops below the voltage level of the battery. sram contents are protected while battery voltage is greater than 2.0v. pin pc4 on port c can be used as an output to indicate that a battery switch-over has occurred. this is configured in psdsoft express by selecting the ?standby on indicator? option for pin pc4. 28.6 psd module reset conditions the psd module receives a reset signal from the mcu module. this reset signal is referred to as the ?rst ? input in psd module documentation, and it is active-low when asserted. the character of the rst signal generated from the mcu module is described in section 19: supervisory functions on page 83 . upon power-up, and while rst is asserted, the psd module immediately loads its configuration from non-volatile bits to configure the plds and other items. pld logic is operational and ready for use well before rst is de-asserted. the state of pld outputs are determined by equations specified in psdsoft express. the flash memories are reset to read array mode after any assertion of rst (even if a program or erase operation is occurring). flash memory write operations are automatically prevented while v dd is ramping up until it rises above the v lko voltage threshold at which time flash memory write operations are allowed. once the upsd34xx is up and running, any subsequent reset operation is referred to as a warm reset, until power is turned off again. some psd module functions are reset in different ways depending if the reset condition was caused from a power-up reset or a warm reset. table 148 on page 251 summarizes how psd module functions are affected by power-up and warm resets, as well as the affect of psd module power-down mode (from apd). the i/o pins of psd module ports a, b, c, and d do not have weak internal pull-ups. in mcu i/o mode, latched address out mode, and peripheral i/o mode, the pins of ports a, b, c, and d become standard cmos inputs during a reset condition. if no external devices are driving these pins during reset, then these inputs may float and draw excessive current. if low power consumption is critical du ring reset, then these floating inputs should be pulled up externally to v dd with a weak (100k ? minimum) resistor.
upsd34xx psd module 251/293 in pld i/o mode, pins of ports a, b, c, and d may also float during reset if no external device is driving them, and if there is no equation specified for the dpld or gpld to make them an output. in this case, a weak external pull-up resistor (100k ? minimum) should be used on floating pins to avoid excessive current draw. the pins on ports 1, 3, and 4 of the 8032 mcu module do have weak internal pull-ups and the inputs will not float, so no external pull-ups are needed. table 148. function status during power-up reset, warm reset, power-down mode note: 1 vm register bit 7 (pio_en) and bit 0 (sram in 8032 program space) are cleared to zero at power-up and warm reset conditions. 28.6.1 jtag isp and jtag debug an ieee 1149.1 serial jtag interface is us ed on upsd34xx devices for isp (in-system programming) of the psd module, and also for debugging firmware on the mcu module. ieee 1149.1 boundary scan operations are not su pported in the upsd34xx. the main advantage of jtag isp is that a blank upsd34xx device may be soldered to a circuit board and programmed with no involvement of the 8032, meaning that no 8032 port configuration power-up reset warm reset apd power-down mode mcu i/o pins are in input mode pins are in input mode pin logic state is unchanged pld i/o pin logic is valid after internal psd module configuration bits are loaded. happens long before rst is de- asserted pin logic is valid and is determined by pld logic equations pin logic depends on inputs to pld (8032 addresses are blocked from reaching pld inputs during power- down mode) latched address out mode pins are high impedance pins are high impedance pins logic state not defined since 8032 address signals are blocked peripheral i/o mode pins are high impedance pins are high impedance pins are high impedance jtag isp and debug jtag channel is active and available jtag channel is active and available jtag channel is active and available register power-up reset warm reset apd power-down mode pmmr0 and pmmr2 cleared to 00h unchanged unchanged output of omc flip- flops cleared to ?0? depends on .re and .pr equations depends on .re and .pr equations vm register (1) initialized with value that was specified in psdsoft initialized with value that was specified in psdsoft unchanged all other csiop registers cleared to 00h cleared to 00h unchanged
psd module upsd34xx 252/293 firmware needs to be present for isp. this is good for manufacturing, for field updates, and for easy code development in the lab. jtag-based programmers and debuggers for upsd34xx are available from stmicroelectronics and 3rd party vendors. isp is different than iap (in-application programming). iap involves the 8032 to program flash memory over any interface supported by the 8032 (e.g., uart, spi, i2c), which is good for remote updates over a communication channel. upsd34xx devices support both isp and iap. the entire psd module (flash memory and pld) may be programmed with jtag isp, but only the flash memories may be programmed using iap. 28.6.2 jtag chaining inside the package jtag protocol allows serial ?chaining? of more than one device in a jtag chain. the upsd34xx is assembled with a stacked die process combining the psd module (one die) and the mcu module (the other die). these two die are chained together within the upsd34xx package. the standard jtag interface has four basic signals: tdi - serial data into device tdo - serial data out of device tck - common clock tms - mode selection every device that supports ieee 1149.1 jtag communication contains a test access port (tap) controller, which is a small state machine to manage jtag protocol and serial streams of commands and data. both the psd module and the mcu module each contain a tap controller. figure 91 illustrates how these die are chained wit hin a package. jtag programming/test equipment will connect exte rnally to the four ieee 1149.1 jtag pins on port c. the tdi pin on the upsd34xx package goes directly to the psd module first, then exits the psd module through tdo. tdo of the psd module is connected to tdi of the mcu module. the serial path is completed when tdo of the mcu module exits the upsd34xx package through the tdo pin on port c. the jtag signals tck and tms are common to both modules as specified in ieee 1149.1. when jtag device s are chained, typically one devices is in bypass mode while another device is executin g a jtag operation. for the upsd34xx, the psd module is in bypass mode while debugging the mcu m odule, and the mcu module is in bypass mode while perfor ming isp on the psd module. the reset_in input pin on the upsd34xx package goes to the mcu module, and this module will generate the rst reset signal for the psd module. these reset signals are totally independent of the jtag tap controllers, meaning that the jtag channel is operational when the modules are held in reset. it is re quired to assert reset_in during isp. stmicroelectronics and 3rd party jtag isp tools will automatically assert a reset signal during isp. however, the user must connect this reset signal to reset_in as shown in examples in figure 92 on page 254 and figure 93 on page 255 .
upsd34xx psd module 253/293 figure 91. jtag chain in upsd34xx package 28.6.3 in-system programming the isp function can use two different configurations of the jtag interface: 4-pin jtag: tdi, tdo, tck, tms 6-pin jtag: signals above plus tstat, terr at power-up, the four basic jtag signals are all inputs, waiting for a command to appear on the jtag bus from programming or test equipment. when the enabling command is received, tdo becomes an output and the jtag channel is fully functional. the same command that enables the jtag channel may optionally enable the two additional signals, tstat and terr . 28.6.4 4-pin jtag isp (default) the four basic jtag pins on port c are enabled for jtag operation at all times. these pins may not be used for other i/o functions. there is no action needed in psdsoft express to configure a device to use 4-pin jtag, as this is the default condition. no 8032 firmware is needed to use 4-pin isp because all isp functions are controlled from the external jtag program/test equipment. figure 92 shows recommended connections on a circuit board to a jtag program/test tool using 4-pin jtag. it is required to connect the rst output signal from the jtag prog ram/test equipment to the reset_in input on the upsd34xx. the rst signal is driven by the equipment with an open drain driver, allowing other sources (like a push button) to drive reset_in without conflict. note: the recommended pull-up resistors and de coupling capacitor are illustrated in figure 92 . jtag tdi jtag tms jtag tck jtag tdo tdi tms tck tdo tdo tms tck tdi pc3 / tstat pc4 / terr t s tat terr optional jtag tap controller jtag tap controller reset_in optional debug reset rst 8032 mcu mcu module psd module main flash memory 2nd flash memory pld upsd34xx ieee 1149.1 ai10460
psd module upsd34xx 254/293 figure 92. recommended 4-pin jtag connections note: 1 for 5v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 5v system v dd . 2 for 3.3v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 3.3v system v cc . 3 this signal is driven by an open-drain output in the jtag equipment, allowing more than one source to activate reset in. 28.6.5 6-pin jtag isp (optional) the optional signals tstat and terr are programming status flags that can reduce programming time by as much as 30% compared to 4-pin jtag because this status information does not have to be scanned out of the device serially. tstat and terr must be used as a pair for 6-pin jtag operation. tstat (pin pc3) indicates when programming of a single flash location is complete. logic 1 = ready, logic 0 = busy. terr (pin pc4) indicates if there was a flash programming error. logic 1 = no error, logic 0 = error. the pin functions for pc3 and pc4 must be selected as ?dedicated jtag - tstat? and ?dedicated jtag - terr ? in psdsoft express to enable 6-pin jtag isp. no 8032 firmware is needed to use 6-pin isp because all isp functions are controlled from the external jtag program/test equipment. tms - pc0 tck - pc1 sram stby or i/o - pc2 general i/o - pc3 general i/o - pc4 tdi - pc5 tdo - pc6 general i/o - pc7 jtag conn. 100k typical tms tck tdi tdo general i/o signals gnd v cc (1,2) rst (3) upsd34xx 0.01 f circuit board jtag programming or test equipment connects here 10k push button or any other reset source debug optional test point 100k resetin ai10457
upsd34xx psd module 255/293 tstat and terr are functional only when jtag isp operations are occurring, which means they are non-functional during jtag debugging of the 8032 on the mcu module. programming times vary depending on the number of locations to be programmed and the jtag programming equipment, but typical jtag isp programming times are 10 to 25 seconds using 6-pin jtag. the signals tstat and terr are not included in the ieee 1149.1 specification. figure 93 on page 255 shows recommended connections on a circuit board to a jtag program/test tool using 6-pin jtag. it is required to connect the rst output signal from the jtag program/test equipment to the reset_in input on the upsd34xx. the rst signal is driven by the equipment with an open drain driver, allowing other sources (like a push button) to drive reset_in without conflict. note: the recommended pull-up resistors and de coupling capacitor are illustrated in figure 93 . figure 93. recommended 6-pin jtag connections note: 1 for 5v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 5v system v dd . 2 for 3.3v upsd34xx devices, pull-up resistors and v cc pin on the jtag connector should be connected to 3.3v system v cc . 3 this signal is driven by an open-drain output in the jtag equipment, allowing more than one source to activate reset_in . tms - pc0 tck - pc1 sram stby or i/o - pc2 tstat - pc3 terr - pc4 tdi - pc5 tdo - pc6 general i/o - pc7 jtag conn. 100k typical tms tck tdi terr t s tat tdo general i/o signals gnd v cc (1,2) rst (3) upsd34xx 0.01 f circuit board jtag programming or test equipment connects here 10k push button or any other reset source debug optional test point 100k resetin ai10458
psd module upsd34xx 256/293 28.6.6 recommended jtag connector there is no industry standard jtag connector. stmicroelectronics recommends a specific jtag connector and pinout for upsd3xxx so programming and debug equipment will easily connect to the circuit board. the user does not have to use this connector if there is a different connection scheme. the recommended connector scheme can accept a standard 14-pin ribbon cable connector (2 rows of 7 pins on 0.1? centers, 0.025? square posts, standard keying) as shown in figure 94 . see the stmicroelectroni cs ?flashlink, fl-101 user manual? for more information. figure 94. recommended jtag connector 28.6.7 chaining upsd34xx devices it is possible to chain a upsd34xx device wit h other upsd34xx devices on a circuit board, and also chain with ieee 1149.1 compliant devices from other manufacturers. figure 95 on page 257 shows a chaining example. the tdo of one device connects to the tdi of the next device, and so on. only one device is performing jtag operations at any given time while the other two devices are in bypass mode. config uration for jtag chaini ng can be made in psdsoft express by choosing ?more than o ne device? when prompted about chaining devices. notice in figure 95 on page 257 that the upsd34xx devices are chained externally, but also be aware that the two die within each upsd34xx device are chained internally. this internal chaining of die is transparent to the user and is taken care of by psdsoft express and 3rd party jtag tool software. the example in figure 95 on page 257 also shows how to use 6-pin jtag when chaining devices. the signals tstat and terr are configured as open-drain type signals from psdsoft express. this facilitates a wired-or connection of tstat signals from multiple upsd34xx devices and also a wired-or connection of terr signals from those same multiple devices. psdsoft express puts tstat and terr signals into open-drain mode by default, requiring external pull-up resistors. click on 'properties' in the jtag-isp window of psdsoft express to change to standard cmos push-pull outputs if desired, but wired-or logic is not possible in cmos output mode. tdo tck tms v cc tdi gnd jen terr gnd gnd rst tstat cntl trst 14 12 10 13 11 9 7 8 6 5 4 3 2 1 key way view: looking into face of shrouded male connector, with 0.025" posts on 0.1" centers. connector reference: molex 70247-1401 this connector accepts a 14-pin ribbon cable such as:  samtec: hcsd-07-d-06.00-01-s-n  digikey: m3cck-14065-nd ai09187
upsd34xx psd module 257/293 figure 95. example of chaining upsd34xx devices 28.6.8 debugging the 8032 mcu module the 8032 on the mcu module may be debugged in-circuit using the same four basic jtag signals as used for jtag isp (tdi, tdo, tck, tms). the signals tstat and terr are not needed for debugging, and they will not create a problem if th ey exist on the circuit board while debugging. the same connector specified in figure 94 on page 256 can be used for isp or for 8032 debugging. there are 3rd party suppliers of upsd34xx jtag debugging equipment (check www.st.com/psm). these are small pods which connect to a pc (or notebook computer) using a usb interface, and they are driven by an 8032 integrated development environment (ide) running on the pc. standard debugging features are provided through this jtag interface such as single-step, breakpoints, trace, memory dump and fill, an d others. there is also a dedicated debug pin (shown in figure 91 on page 253 ) which can be configured as an output to trigger external devices upon a programmable internal event (e.g., breakpoint match), or the pin can be configured as an input so an external device can initiate an internal debug event (e.g., break execution). the debug pin function is configured by the 8032 ide debug software tool. see section 12: debug unit on page 50 for more details. the debug signal should always be pulled up externally with a weak pull-up (100k minimum) to v cc even if nothing is connected to it, as shown in figure 92 on page 254 and figure 93 on page 255 . device 1 psd34xx upsd34xx tms tck tdi tdo ieee 1149.1 compliant device device 2 device n system reset circuitry tms tck tdi tdo t s tat terr circuit board jtag conn. v cc tms tck tdi t s tat terr tdo rst gnd 100k 100k 100k 100k 100k 10k 100k jtag programming or test equipment connects here optional optional tms tck tdi tdo t s tat terr ai10459
psd module upsd34xx 258/293 28.6.9 jtag security setting a programmable security bit in the psd module protects its contents from unauthorized viewing and copying. the security bit is set by clicking on the ?additional psd settings? box in the main flow diagram of psdsoft express, then choosing to set the security bit. once a file with this setting is programmed into a upsd34xx using jtag isp, any further attempts to communicate with the upsd34xx using jtag will be limited. once secured, the only jtag operation allowed is a full-chip erase. no reading or modifying flash memory or pld logic is allowed. debugging operations to the mcu module are also not allowed. the only way to defeat the security bit is to perform a jtag isp full-chip erase operation, after which the device is blank and may be used again. th e 8032 on the mcu module will always have access to psm module memory contents through the 8-bit 8032 data bus connecting the two die, even while the security bit is set. 28.6.10 initial delivery state when delivered from stmicroelectronics, upsd34xx devices are erased, meaning all flash memory and pld configuration bits are logic '1.' firmware and pld logic configuration must be programmed at least the first time using jtag isp. subsequent programming of flash memory may be performed using jtag isp, jtag debugging, or the 8032 may run firmware to program flash memory (iap).
upsd34xx ac/dc parameters 259/293 29 ac/dc parameters these tables describe the ad and dc parameters of the upsd34xx devices: dc electrical specification ac timing specification pld timing ? combinatorial timing ? synchronous clock mode ? asynchronous clock mode ? input macrocell timing mcu module timing ? read timing ? write timing ? power-down and reset timing the following are issues concerning the parameters presented: in the dc specification the supply current is given for different modes of operation. the ac power component gives the pld, flash memory, and sram ma/mhz specification. figure 96 and figure 97 show the pld ma/mhz as a function of the number of product terms (pt) used. in the pld timing parameters, add the required delay when turbo bit is '0.' figure 96. pld i cc / frequency consumption (5v range) 0 10 20 30 40 60 70 80 90 100 110 v cc = 5v 50 01015 5 20 25 highest composite frequency at pld inputs (mhz) i cc ? (ma) turbo on (100%) turbo on (25%) turbo off turbo off pt 100% pt 25% ai02894
ac/dc parameters upsd34xx 260/293 figure 97. pld i cc / frequency consumption (3v range) table 149. psd module example, typ. power calculation at v cc = 5.0v (turbo mode off) conditions mcu clock frequency = 12mhz highest composite pld input frequency (freq pld) = 8mhz mcu ale frequency (freq ale) = 2mhz % flash memory access = 80% % sram access = 15% % i/o access = 5% (no additional power above base) operational modes % normal = 40% % power-down mode = 60% number of product terms used (from fitter re port) = 45 pt % of total product terms = 45/182 = 24.7% turbo mode = off calculation (using typical values) i cc total = i cc (mcuactive) x %mcuactive + i cc (psdactive) x %psdactive + i pd (pwrdown) x %pwrdown 0 10 20 30 40 50 60 v cc = 3v 01015 5 20 25 i cc ? (ma) turbo on (100%) turbo on (25%) turbo off turbo off highest composite frequency at pld inputs (mhz) pt 100% pt 25% ai03100
upsd34xx ac/dc parameters 261/293 i cc (mcuactive) = 20ma i pd (pwrdown) = 250ua i cc (psdactive) = i cc (ac) + i cc (dc) = %flash x 2.5ma/mhz x freq ale + %sram x 1.5ma/mhz x freq ale + % pld x (from graph using freq pld) = 0.8 x 2.5ma/mhz x 2mhz + 0.15 x 1.5ma/mhz x 2mhz + 24ma = (4 + 0.45 + 24) ma = 28.45ma i cc total = 20ma x 40% + 28.45ma x 40% + 250ua x 60% = 8ma + 11.38ma + 150ua = 19.53ma this is the operating power with no flash memory erase or program cycles in progress. calculation is based on all i/o pins being disconnected and i out = 0ma. conditions
maximum rating upsd34xx 262/293 30 maximum rating stressing the device above the rating listed in the absolute maximum ratings? table may cause permanent damage to the device. these are stress ratings only and operation of the device at these or any other conditions above those indicated in the operating sections of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. refer also to the stmicroelectronics sure program and other relevant quality documents. table 150. absolute maximum ratings note: 1 ipc/jede c j-std-020a 2 jedec std jesd22-a114a (c1=100pf, r1=1500 ? , r2=500 ? ) symbol parameter min. max. unit t stg storage temperature ?65 125 c t lead lead temperature during soldering (20 seconds max.) (1) 235 c v io input and output voltage (q = v oh or hi-z) ?0.5 6.5 v v cc , v dd , av cc supply voltage ?0.5 6.5 v v esd electrostatic discharge voltage (human body model) (2) ?2000 2000 v
upsd34xx dc and ac parameters 263/293 31 dc and ac parameters this section summarizes the operating and measurement conditions, and the dc and ac characteristics of the device. the parameters in the dc and ac characteristic tables that follow are derived from tests performed under the measurement conditions summarized in the relevant tables. designers should check that the operating conditions in their circuit match the measurement conditions when relying on the quoted parameters. table 151. operating conditions (5v devices) table 152. operating conditions (3.3v devices) table 153. ac signal letters for timing note: example: t avlx = time from address valid to ale invalid. symbol parameter min. max. unit v dd supply voltage 4.5 5.5 v v cc , av cc supply voltage 3.0 3.6 v t a ambient operating temperature (industrial) ?40 85 c ambient operating temperature (commercial) 070c symbol parameter min. max. unit v cc , v dd , av cc supply voltage 3.0 3.6 v t a ambient operating temperature (industrial) ?40 85 c ambient operating temperature (commercial) 070c aaddress c clock d input data i instruction lale n reset input or output p psen signal q output data r rd signal w wr signal bv stby output m output macrocell
dc and ac parameters upsd34xx 264/293 table 154. ac signal behavior symbols for timing note: example: t avlx = time from address valid to ale invalid. figure 98. switching waveforms ? key table 155. major parameters ttime l logic level low or ale h logic level high v valid x no longer a valid logic level z float pw pulse width parameter test conditions/comments 5.0v value 3.3v value unit operating voltage ? 4.5 to 5.5 (psd); 3.0 to 3.6 (mcu) 3.0 to 3.6 (psd and mcu) v operating temperature ? ?40 to 85 ?40 to 85 c mcu frequency 8mhz (min) for i 2 c 3 min, 40 max 3 min, 40 max mhz operating current, typical (1) (20% of pld used; 25c operation. bus control signals are blocked from the pld in non-turbo mode.) 40mhz crystal, turbo 79 63 ma 40mhz crystal, non-turbo 71 58 ma 8mhz crystal, turbo 32 24 ma 8mhz crystal, non-turbo 17.7 14 ma waveforms inputs outputs steady input may change from hi to lo may change from lo to hi don't care outputs only steady output will be changing from hi to lo will be changing lo to hi changing, state unknown center line is tri-state ai03102
upsd34xx dc and ac parameters 265/293 note: 1 operating current is measured while the upsd34xx is executing a typical program at 40mhz. table 156. mcu module dc characteristics idle current, typical (20% of pld used; 25c operation) 40mhz crystal divided by 2048 internally. all interfaces are disabled. 19 18 ma standby current, typical power-down mode needs reset to exit. 140 120 a sram backup current, typical if external battery is attached. 0.5 0.5 a i/o sink/source current, ports a, b, c, and d v ol = 0.45v (max); v oh = 2.4v (min) i ol = 8 (max); i oh = ?2 (min) i ol = 4 (max); i oh = ?1 (min) ma i/o sink/source current, port 4 v ol = 0.6v (max); v oh = 2.4v (min) i ol = 10 (max); i oh = ?10 (min) i ol = 10 (max); i oh = ?10 (min) ma pld macrocells for registered or combinatorial logic 16 16 ? pld inputs inputs from pins, feedback, or mcu addresses 69 69 ? pld outputs output to pins or internal feedback 18 18 ? pld propagation delay, typical, turbo mode pld input to output 15 22 ns parameter test conditions/comments 5.0v value 3.3v value unit symbol parameter test cond itions min. typ. max. unit v cc , av cc supply voltage (1) 3.0 3.6 v v ih high level input voltage (ports 0, 1, 3, 4, xtal1, reset) 5v tolerant - max voltage 5.5v 3.0v < v cc < 3.6v 0.7v cc 5.5 (2) v v il low level input voltage (ports 0, 1, 3, 4, xtal1, reset) 3.0v < v cc < 3.6v v ss ? 0.5 0.3v cc v v ol1 output low voltage (port 4) i ol = 10ma 0.6 v v v ol2 output low voltage (other ports) i ol =5ma 0.6 v v
dc and ac parameters upsd34xx 266/293 note: 1 power supply (v cc , av cc ) is always 3.0 to 3.6v for the mcu module. v dd for the psd module may be 3v or 5v. 2 port 1 is not 5v tolerant; maximum v ih = v cc + 0.5. 3i pd (power-down mode) is measured with: xtal1 = v ss ; xtal2 = nc; reset = v cc ; port 0 = v cc ; all other pins are disconnected. 4i cc-cpu (active mode) is measured with: xtal1 driven with t clch , t chcl = 5ns, v il = v ss + 0.5v, v ih = v cc ? 0.5v, xtal2 = nc; reset = v ss ; port 0 = v cc ; all other pins are disconnected. i cc would be slightly higher if a crystal oscillator is used (approximately 1ma). 5i cc-cpu (idle mode) is measured with: xtal1 driven with t clch , t chcl = 5ns, v il = v ss + 0.5v, v ih = v cc ? 0.5v, xtal2 = nc; reset = v cc ; port 0 = v cc ; all other pins are disconnected. i cc would be slightly higher if a crysta l oscillator is used (approximately 1ma). all ip clocks are disabled and the mcu clock is set to f osc /2048. 6 i/o current = 0ma, all i/o pins are disconnected. v oh1 output high voltage (ports 4 push-pull) i oh = ?10ma 2.4 v v v oh2 output high voltage (port 0 push-pull) i oh = ?5ma 2.4 v v v oh3 output high voltage (other ports bi-directional mode) i oh = ?20a 2.4 v v v op xtal open bias voltage (xtal1, xtal2) i ol = 3.2ma 1.0 2.0 v i rst reset pin pull-up current (reset) v in = v ss ?10 ?55 ua i fr xtal feedback resistor current (xtal1) xtal1 = v cc ; xtal2 = v ss ?20 50 ua i ihl1 input high leakage current (port 0) v ss < v in < 5.5v ?10 10 ua i ihl2 input high leakage current (port 1, 3, 4) v ih = 2.3v ?10 10 ua i ill input low leakage current (port 1, 3, 4) v il < 0.5v ?10 10 ua i pd (3) power-down mode v cc = 3.6v 65 95 ua i cc-cpu (notes 4,5,6) active - 12mhz v cc = 3.6v 14 20 ma idle - 12mhz 10 12 ma active - 24mhz v cc = 3.6v 19 30 ma idle - 24mhz 13 17 ma active - 40mhz v cc = 3.6v 26 40 ma idle - 40mhz 17 22 ma symbol parameter test cond itions min. typ. max. unit
upsd34xx dc and ac parameters 267/293 table 157. psd module dc characteristics (with 5v v dd ) note: 1 internal power-down mode is active. 2 pld is in non-turbo mode, and none of the inputs are switching. 3 please see figure 96 on page 259 for the pld current calculation. 4i out = 0ma symbo l parameter test condition (in addition to those in table 156 on page 265 ) min. typ. max. unit v ih input high voltage 4.5v < v dd < 5.5v 2 v dd +0.5 v v il input low voltage 4.5v < v dd < 5.5v ?0.5 0.8 v v lko v dd (min) for flash erase and program 2.5 4.2 v v ol output low voltage i ol = 20ua, v dd = 4.5v 0.01 0.1 v i ol = 8ma, v dd = 4.5v 0.25 0.45 v v oh output high voltage except v stby on i oh = ?20ua, v dd = 4.5v 4.4 4.49 v i oh = ?2ma, v dd = 4.5v 2.4 3.9 v v oh1 output high voltage v stby on i oh1 = 1ua v stby ? 0.8 v v stby sram stand-by voltage 2.0 v dd v i stby sram stand-by current v dd = 0v 0.5 1 ua i idle idle current (v stby input) v dd > v stby ?0.1 0.1 ua v df sram data retention voltage only on v stby 2v dd ? 0.2 v i sb stand-by supply current for power-down mode csi > v dd ? 0.3v (notes 1,2) 120 250 ua i li input leakage current v ss < v in < v dd ?1 0.1 1 ua i lo output leakage current 0.45 < v out < v dd ?10 5 10 ua i cc (dc) (note 4) operating supply current pld only pld_turbo = off, f = 0mhz (note 4) 0 ua/p t pld_turbo = on, f = 0mhz 400 700 ua/p t flash memory during flash memory write/erase only 15 30 ma read only, f = 0mhz 0 0 ma sram f = 0mhz 0 0 ma i cc (ac) (note 4) pld ac adder note 3 flash memory ac adder 1.5 2.5 ma/m hz sram ac adder 1.5 3.0 ma/m hz
dc and ac parameters upsd34xx 268/293 table 158. psd module dc characteristics (with 3.3v v dd ) note: 1 internal pd is active. 2 pld is in non-turbo mode, and none of the inputs are switching. 3 please see figure 97 on page 260 for the pld current calculation. 4i out = 0ma symb. parameter test condition (in addition to those in table 156 on page 265 ) min. typ. max. unit v ih high level input voltage 3.0v < v dd < 3.6v 0.7v dd v dd +0.5 v v il low level input voltage 3.0v < v dd < 3.6v ?0.5 0.8 v v lko v dd (min) for flash erase and program 1.5 2.2 v v ol output low voltage i ol = 20ua, v dd = 3.0v 0.01 0.1 v i ol = 4ma, v dd = 3.0v 0.15 0.45 v v oh output high voltage except v stby on i oh = ?20ua, v dd = 3.0v 2.9 2.99 v i oh = ?1ma, v dd = 3.0v 2.7 2.8 v v oh1 output high voltage v stby on i oh1 = 1ua v stby ? 0.8 v v stby sram stand-by voltage 2.0 v dd v i stby sram stand-by current v dd = 0v 0.5 1 ua i idle idle current (v stby input) v dd > v stby ?0.1 0.1 ua v df sram data retention voltage only on v stby 2v dd ? 0.2 v i sb stand-by supply current for power-down mode csi > v dd ? 0.3v (notes 1,2) 50 100 ua i li input leakage current v ss < v in < v dd ?1 0.1 1 ua i lo output leakage current 0.45 < v in < v dd ?10 5 10 ua i cc (dc) (note 4) operating supply current pld only pld_turbo = off, f = 0mhz (note 2) 0 ua/p t pld_turbo = on, f = 0mhz 200 400 ua/p t flash memory during flash memory write/erase only 10 25 ma read only, f = 0mhz 0 0 ma sram f = 0mhz 0 0 ma i cc (ac) (note 4) pld ac adder note 3 flash memory ac adder 1.0 1.5 ma/ mhz sram ac adder 0.8 1.5 ma/ mhz
upsd34xx dc and ac parameters 269/293 figure 99. external read cycle (80-pin device only) table 159. external read cycle ac characteristics (3v or 5v device) note: 1 buscon register is configured for 4 pfqclk. 2 refer to ta b l e 1 6 0 for ?n? and ?m? values. table 160. n, m, and x, y values symbol parameter 40mhz oscillator (1) variable oscillator 1/t clcl = 3 to 40mhz unit min max min max t lhll ale pulse width 17 t clcl ? 8 ns t avll address setup to ale 13 t clcl ? 12 ns t llax address hold after ale 7.5 0.5t clcl ? 5 ns t llrl ale to rd 7.5 0.5t clcl ? 5 ns t rlrh rd pulse width (2) 40 nt clcl ? 10 ns t rxix input data hold after rd 22ns t rhiz input data float after rd 10.5 0.5t clcl ? 2 ns t avdx address to valid data in (2) 70 mt clcl ? 5 ns t azrl address float to rd ?2 ?2 ns t avqv address valid to latched address out on ports a and b 35.5 (3v) 1.5t clcl ? 2 ns 28 (5v) t clcl ? 9.5 ns t avll t rlrh t rxdz mcu ad0 - ad7 latched mcu a8 - a15 ai10471 t lhll ale rd t llrl a0-a7 t llax t azrl t avdv a0-a7 t rxdx t avqv a8-a15 data in a8-a15 # of pfqclk in buscon reg. read cycle write cycle nmx y 42321 53432
dc and ac parameters upsd34xx 270/293 figure 100. external write cycle (80-pin device only) table 161. external write cycle ac characteristics (3v or 5v device) 64543 75654 symbol parameter 40mhz oscillator (1) variable oscillator 1/t clcl = 3 to 40mhz unit min max min max t lhll ale pulse width 17 t clcl ? 8 ns t avll address setup to ale 13 t clcl ? 12 ns t llax address hold after ale 7.5 0.5t clcl ? 5 ns t wlwh wr pulse width (2) 40 xt clcl ? 10 ns t llwl ale to wr 7.5 0.5t clcl ? 5 ns t avwl address (a0-a7) valid to wr (3) 32.5 1.5t clcl ? 5 ns t whlh wr high to ale high 9.5 9.5 0.5t clcl ? 3 0.5t clcl + 2 ns t qvwh data setup before wr (y) 20 yt clcl ? 5 ns t whqx data hold after wr 9.5 14.5 0.5t clcl ? 3 0.5t clcl + 2 ns t avqv address valid to latched address out on ports a and b 35.5 (3v) 1.5t clcl ? 2 ns 28 (5v) t clcl ? 9.5 ns # of pfqclk in buscon reg. read cycle write cycle nmx y latched mcu a8 - a15 mcu ad0 - ad7 ale wr rd a8-a15 a8-a15 tllwl twlwh tavll tlhll tqvwh data out a0-a7 data in a0-a7 tllax tavwl tavqv twhqx twhlh ai10472
upsd34xx dc and ac parameters 271/293 note: 1 buscon register is configured for 4 pfqclk. 2 refer to table 162 on page 271 , for ?n? and ?m? values. 3 latched address out on ports a and b to wr is 2ns, minimum. table 162. external clock drive table 163. a/d analog specification note: 1 f in 2khz, aclk = 8mhz, av ref = av cc = 3.3v 2av ref = av cc in 52-pin package. 3 if the a/d converter is not used, connect av cc /av ref to v cc . symbol parameter (1) 40mhz oscillator variable oscillator 1/t clcl = 3 to 40mhz unit min max min max t clcl oscillator period 25 333 ns t chcx high time 10 t clcl ? t clcx ns t clcx low time 10 t clcl ? t clcx ns t clch rise time 10 ns t chcl fall time 10 ns symbol parameter test conditions (1) min. typ. max. unit i dd normal input = av ref 4.0 ma power-down 40 ua av in analog input voltage gnd av ref v av ref (2)( 3) analog reference voltage 3.6 v accuracy resolution 10 bits inl integral nonlinearity input = 0 to av ref (v) f osc 32mhz 2 lsb dnl differential nonlinearity input = 0 to av ref (v) f osc 32mhz 2 lsb snr signal to noise ratio f sample = 500ksps 50 54 db sndr signal to noise distortion ratio 48 52 db aclk adc clock 2 8 16 mhz t c conversion time 8mhz 1 4 8 s t cal power-up time calibration time 16 ms f in analog input frequency 60 khz thd total harmonic distortion 50 54 db
dc and ac parameters upsd34xx 272/293 table 164. usb transceiver specification note: 1 temperature range = ?45c to 85c. 2 this value includes an external resistor of 24 ? 1%. figure 101. input to output disable / enable table 165. cpld combinatorial timing (5v psd module) symbol parameter test conditions (1) min. typ. max. unit uv oh high output voltage v dd = 3.3v; i out = 2.2ma 3?v uv ol low output voltage vdd = 3.3v; i out = 2.2ma ?0.25v uv ih high input voltage vdd = 3.6v 2 ? v uv il low input voltage vdd = 3.6v 0.8 v r dh output impedance (high state) note 2 28 43 ? r dl output impedance (low state) note 2 28 43 ? i l input leakage current v dd = 3.6v 0.1 5 a i oz 3-state output off state current vi = v ih or v il 10 a v cr crossover point 1.3 2 v t rise rise time 4 20 ns t fall fall time 4 20 ns symbol parameter conditions min max pt aloc turbo off slew rate (1) unit t pd (2) cpld input pin/feedback to cpld combinatorial output 20 + 2 + 10 ? 2 ns t ea cpld input to cpld output enable 21 + 10 ? 2 ns t er cpld input to cpld output disable 21 + 10 ? 2 ns t arp cpld register clear or preset delay 21 + 10 ? 2 ns ter tea input input to output enable/disable ai02863
upsd34xx dc and ac parameters 273/293 note: 1 fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount 2t pd for mcu address and control signals refers to delay from pins on port 0, port 2, rd wr , psen and ale to cpld combinatorial output (80-pin package only) table 166. cpld combinatorial timing (3v psd module) note: 1 fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount 2t pd for mcu address and control signals refers to delay from pins on port 0, port 2, rd wr , psen and ale to cpld combinatorial output (80-pin package only) figure 102. synchronous clock mode timing ? pld t arpw cpld register clear or preset pulse width 10 + 10 ns t ard cpld array delay any macrocell 11 + 2 ns symbol parameter conditions min max pt aloc turbo off slew rate (1) unit symbol parameter conditions min max pt aloc turbo off slew rate (1) unit t pd (2) cpld input pin/feedback to cpld combinatorial output 35 + 4 + 15 ? 6 ns t ea cpld input to cpld output enable 38 + 15 ? 6 ns t er cpld input to cpld output disable 38 + 15 ? 6 ns t arp cpld register clear or preset delay 35 + 15 ? 6 ns t arpw cpld register clear or preset pulse width 18 + 15 ns t ard cpld array delay any macrocell 20 + 4 ns t ch t cl t co t h t s clkin input registered output ai02860
dc and ac parameters upsd34xx 274/293 table 167. cpld macrocell synchronous clock mode timing (5v psd module) note: 1 fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount. 2clkin (pd1) t clcl = t ch + t cl . table 168. cpld macrocell synchronous clock mode timing (3v psd module) note: 1 fast slew rate output available on pa3-pa0, pb3-pb0, and pd2-pd1. decrement times by given amount. 2clkin (pd1) t clcl = t ch + t cl . symbol parameter conditions min max pt aloc turbo off slew rate (1) unit f max maximum frequency external feedback 1/(t s +t co ) 40.0 mhz maximum frequency internal feedback (f cnt ) 1/(t s +t co ? 10) 66.6 mhz maximum frequency pipelined data 1/(t ch +t cl ) 83.3 mhz t s input setup time 12 + 2 + 10 ns t h input hold time 0 ns t ch clock high time clock input 6 ns t cl clock low time clock input 6 ns t co clock to output delay clock input 13 ? 2 ns t ard cpld array delay any macrocell 11 + 2 ns t min minimum clock period (2) t ch +t cl 12 ns symbol parameter conditions min max pt aloc turbo off slew rate (1) unit f max maximum frequency external feedback 1/(t s +t co ) 23.2 mhz maximum frequency internal feedback (f cnt ) 1/(t s +t co ?10) 30.3 mhz maximum frequency pipelined data 1/(t ch +t cl ) 40.0 mhz t s input setup time 20 + 4 + 15 ns t h input hold time 0 ns t ch clock high time clock input 15 ns t cl clock low time clock input 10 ns t co clock to output delay clock input 23 ? 6 ns t ard cpld array delay any macrocell 20 + 4 ns t min minimum clock period (2) t ch +t cl 25 ns
upsd34xx dc and ac parameters 275/293 figure 103. asynchronous reset / preset figure 104. asynchronous clock mode timing (product term clock) table 169. cpld macrocell asynchronous clock mode timing (5v psd module) symbo l parameter conditions min max pt aloc turbo off slew rate unit f maxa maximum frequency external feedback 1/(t sa +t coa )38.4 mhz maximum frequency internal feedback (f cnta ) 1/(t sa +t coa ? 10) 62.5 mhz maximum frequency pipelined data 1/(t cha +t cla )71.4 mhz t sa input setup time 7 + 2 + 10 ns t ha input hold time 8 ns t cha clock input high time 9 + 10 ns t cla clock input low time 9 + 10 ns t coa clock to output delay 21 + 10 ? 2 ns t arda cpld array delay any macrocell 11 + 2 ns t mina minimum clock period 1/f cnta 16 ns tarp register output tarpw reset/preset input ai02864 tcha tcla tcoa tha tsa clock input registered output ai02859
dc and ac parameters upsd34xx 276/293 table 170. cpld macrocell asynchronous clock mode timing (3v psd module) figure 105. input macrocell timing (product term clock) table 171. input macrocell timing (5v psd module) note: 1 inputs from port a, b, and c relative to register/ latch clock from the pld. ale/as latch timings refer to t avlx and t lxax . symbol parameter conditions min max pt aloc turbo off slew rate unit f maxa maximum frequency external feedback 1/(t sa +t coa ) 21.7 mhz maximum frequency internal feedback (f cnta ) 1/(t sa +t coa ? 10) 27.8 mhz maximum frequency pipelined data 1/(t cha +t cla ) 33.3 mhz t sa input setup time 10 + 4 + 15 ns t ha input hold time 12 ns t cha clock high time 17 + 15 ns t cla clock low time 13 + 15 ns t coa clock to output delay 31 + 15 ? 6 ns t ard cpld array delay any macrocell 20 + 4 ns t mina minimum clock period 1/f cnta 36 ns symbol parameter condition s min max pt aloc turbo off unit t is input setup time (note 1) 0 ns t ih input hold time (note 1) 15 + 10 ns t inh nib input high time (note 1) 9 ns t inl nib input low time (note 1) 9 ns t ino nib input to combinatorial delay (note 1) 34 + 2 + 10 ns t inh t inl t ino t ih t is pt clock input output ai03101
upsd34xx dc and ac parameters 277/293 table 172. input macrocell timing (3v psd module) note: 1 inputs from port a, b, and c relative to register/latch clock from the pld. ale latch timings refer to t avlx and t lxax . table 173. program, write and erase times (5v, 3v psd modules) note: 1 programmed to all zero before erase. 2 typical after 100k write/erase cycles is 5 seconds. 3 the polling status, dq7, is valid t q7vqv time units before the data byte, dq0-dq7, is valid for reading. symbol parameter conditions min max pt aloc turbo off unit t is input setup time (note 1) 0 ns t ih input hold time (note 1) 25 + 15 ns t inh nib input high time (note 1) 12 ns t inl nib input low time (note 1) 12 ns t ino nib input to combinatorial delay (note 1) 43 + 4 + 15 ns symbol parameter min. typ. max. unit flash program 8.5 s flash bulk erase (1) (pre-programmed) 3 (2) 10 s flash bulk erase (not pre-programmed) 5 s t whqv3 sector erase (pre-programmed) 1 10 s t whqv2 sector erase (not pre-programmed) 2.2 s t whqv1 byte program 14 150 s program / erase cycles (per sector) 100,000 cycles pld program / erase cycles 1,000 cycles t whwlo sector erase time-out 100 s t q7vqv dq7 valid to output (dq7-dq0) valid (data polling) (3) 30 ns
dc and ac parameters upsd34xx 278/293 figure 106. peripheral i/o read timing table 174. port a peripheral data mode read timing (5v psd module) note: 1 any input used to select port a data peripheral mode. 2 data is already stable on port a. table 175. port a peripheral data mode read timing (3v psd module) note: 1 any input used to select port a data peripheral mode. 2 data is already stable on port a. symbol parameter conditions min max turbo off unit t avqv?pa address valid to data valid (note 1) 37 + 10 ns t slqv?pa csi valid to data valid 27 + 10 ns t rlqv?pa rd to data valid (note 2) 32 ns t dvqv?pa data in to data out valid 22 ns t rhqz?pa rd to data high-z 23 ns t rlqv ( pa) t dvqv ( pa) t rhqz ( pa) t slqv ( pa) t avqv ( pa) address data valid ale a /d bus rd data on port a csi ai06610 symbol parameter conditions min max turbo off unit t avqv?pa address valid to data valid (note 1) 50 + 15 ns t slqv?pa csi valid to data valid 37 + 15 ns t rlqv?pa rd to data valid (note 2) 45 ns t dvqv?pa data in to data out valid 38 ns t rhqz?pa rd to data high-z 36 ns
upsd34xx dc and ac parameters 279/293 figure 107. peripheral i/o write timing table 176. port a peripheral data mode write timing (5v psd module) note: 1 data stable on port 0 pins to data on port a. table 177. port a peripheral data mode write timing (3v psd module) note: 1 data stable on port 0 pins to data on port a. table 178. supervisor reset and lvd note: 1 25s minimum to abort a flash memory program or erase cycle in progress. 2 as f osc decreases, t rst_actv increases. example: t rst_actv = 50ms when f osc = 8mhz. symbol parameter conditions min max unit t wlqv?pa wr to data propagation delay 25 ns t dvqv?pa data to port a data propagation delay (note 1) 22 ns t whqz?pa wr invalid to port a tri-state 20 ns tdvqv (pa) twlqv (pa) twhqz (pa) address data out a /d bus wr port a data out ale ai06611 symbol parameter conditions min max unit t wlqv?pa wr to data propagation delay 42 ns t dvqv?pa data to port a data propagation delay (note 1) 38 ns t whqz?pa wr invalid to port a tri-state 33 ns symbol parameter conditions min typ max unit t rst_lo_in reset input duration 1 (1) s t rst_actv generated reset duration f osc = 40mhz 10 (2) ms t rst_fil reset input spike filter 1 s v rst_hys reset input hysteresis v cc = 3.3v 0.1 v v rst_thre sh lv d tr i p t h r e s h o l d v cc = 3.3v 2.4 2.6 2.8 v
dc and ac parameters upsd34xx 280/293 table 179. v stbyon definitions timing (5v, 3v psd modules) note: 1 v stbyon timing is measured at v cc ramp rate of 2ms. figure 108. isc timing table 180. isc timing (5v psd module) symbol parameter conditions min typ max unit t bvbh v stby detection to v stbyon output high (note 1) 20 s t bxbl v stby off detection to v stbyon output low (note 1) 20 s symbol parameter conditions min max unit t isccf clock (tck, pc1) frequency (except for pld) (note 1) 20 mhz t iscch clock (tck, pc1) high time (except for pld) (note 1) 23 ns t isccl clock (tck, pc1) low time (except for pld) (note 1) 23 ns t isccfp clock (tck, pc1) frequency (pld only) (note 2) 4 mhz t iscchp clock (tck, pc1) high time (pld only) (note 2) 90 ns t iscclp clock (tck, pc1) low time (pld only) (note 2) 90 ns t iscpsu isc port set up time 7 ns t iscph isc port hold up time 5 ns iscch tck tdi/tms isc outputs/tdo isc outputs/tdo t isccl t iscph t iscpsu t iscpvz t iscpzv t iscpco t ai02865
upsd34xx dc and ac parameters 281/293 note: 1 for non-pld programming, erase or in isc by-pass mode. 2 for program or erase pld only. table 181. isc timing (3v psd module) note: 1 for non-pld programming, erase or in isc by-pass mode. 2 for program or erase pld only. figure 109. mcu module ac measurement i/o waveform note: ac inputs during testing are driven at v cc ?0.5v for a logic '1,' and 0.45v for a logic '0.' note: timing measurements are made at v ih (min) for a logic '1,' and v il (max) for a logic '0' t iscpco isc port clock to output 21 ns t iscpzv isc port high-impedance to valid output 21 ns t iscpvz isc port valid output to high-impedance 21 ns symbol parameter conditions min max unit symbol parameter conditions min max unit t isccf clock (tck, pc1) frequency (except for pld) (note 1) 16 mhz t iscch clock (tck, pc1) high time (except for pld) (note 1) 40 ns t isccl clock (tck, pc1) low time (except for pld) (note 1) 40 ns t isccfp clock (tck, pc1) frequency (pld only) (note 2) 4 mhz t iscchp clock (tck, pc1) high time (pld only) (note 2) 90 ns t iscclp clock (tck, pc1) low time (pld only) (note 2) 90 ns t iscpsu isc port set up time 12 ns t iscph isc port hold up time 5 ns t iscpco isc port clock to output 30 ns t iscpzv isc port high-impedance to valid output 30 ns t iscpvz isc port valid output to high-impedance 30 ns ai06650 v cc ? 0.5v 0.45v test points 0.2 v cc ? 0.1v 0.2 v cc + 0.9v
dc and ac parameters upsd34xx 282/293 figure 110. psd m odule ac float i/o waveform note: for timing purposes, a port pin is considered to be no longer floating when a 100mv change from load voltage occurs, and begins to float when a 100mv change from the loaded v oh or v ol level occurs note: i ol and i oh 20ma figure 111. external clock cycle figure 112. psd module ac measurement i/o waveform figure 113. psd module ac measurement load circuit ai06651 test reference points v ol + 0.1v v oh ? 0.1v v load ? 0.1v v load + 0.1v 0.2 v cc ? 0.1v 3.0v 0v test point 1.5v ai03103b device under test 2.01 v 195 ? c l = 30 pf (including scope and jig capacitance) ai03104b
upsd34xx dc and ac parameters 283/293 table 182. i/o pin capacitance note: 1 sampled only, not 100% tested. 2 typical values are for t a = 25c and nominal supply voltages. 3 maximum for mcu address and data lines is 20pf each. symbol parameter (1) test condition typ. (2) max. unit c in input capacitance (for input pins) v in = 0v 4 6 pf c out output capacitance (for input/output pins) (3) v out = 0v 8 12 pf
package mechanical information upsd34xx 284/293 32 package mechanical information figure 114. tqfp52 ? 52-lead plastic thin, quad, flat package outline table 183. tqfp52 ? 52-lead plastic thin, quad, flat package mechanical data symb typ (mm) min (mm) max (mm) ty p (inch) min (inch) max (inch) a 1.50 ? 1.70 0.059 ? 0.067 a1 0.10 0.05 0.20 0.004 0.002 0.008 a2 1.40 1.30 1.50 0.055 0.039 0.059 b ? 0.20 0.40 ? 0.008 0.016 c ? 0.07 0.20 ? 0.003 0.008 d 12.00 11.80 12.20 0.472 0.465 0.480 d1 10.00 9.80 10.20 0.394 0.386 0.402 d2 7.80 7.67 7.93 0.307 0.302 0.312 e 12.00 11.80 12.20 0.472 0.465 0.480 e1 10.00 9.80 10.20 0.394 0.386 0.402 e2 7.80 7.67 7.93 0.307 0.302 0.312 e0.65? ?0.026? ? l ? 0.45 0.75 ? 0.018 0.030 l1 1.00 ? ? 0.039 ? ? ? 0 7 ? 0 7 n52 52 nd 13 13 ne 13 13 cp??0.10??0.004 qfp-a nd e1 cp b e a2 a n l a1 d1 d 1 e ne c d2 e2 l1 note: drawing is not to scale
upsd34xx package mechanical information 285/293 figure 115. tqfp80 ? 80-lead plastic thin, quad, flat package outline table 184. tqfp80 ? 80-lead plastic thin, quad, flat package mechanical data symb typ (mm) min (mm) max (mm) ty p (inch) min (inch) max (inch) a 1.60 0.063 a1 0.05 0.15 0.002 0.006 a2 1.40 1.35 1.45 0.055 0.053 0.057 b 0.17 0.27 0.007 0.011 c 0.09 0.20 0.004 0.008 d 14.00 0.551 d1 12.00 0.472 d2 9.50 0.374 e 14.00 0.551 e1 12.00 0.472 e2 9.50 0.374 e 0.50 0.020 l 0.45 0.75 0.018 0.030 l1 1.00 0.039 a0707 n80 80 nd 20 20 ne 20 20 cp 0.08 0.003 qfp-a nd e1 cp b e a2 a n l a1 d1 d 1 e ne c d2 e2 l1 note: drawing is not to scale
part numbering upsd34xx 286/293 33 part numbering table 185. ordering information scheme for other options, or for more information on any aspect of this device, please contact the st sales office nearest you. example: upsd3434ev?40u6t device type upsd = microcontroller psd family 34 = turbo plus core sram size 2 = 4kbytes 3 = 8kbytes 5 = 32kbytes main flash memory size 2 = 64kbytes 3 = 128kbytes 4 = 256kbytes ip mix e = ip mix: usb, i 2 c, spi, uart (2), irda, adc, supervisor, pca operating voltage blank: v cc = 3.0 to 3.6v, v dd = 4.5 to 5.5v v: v cc = v dd = 3.0 to 3.6v revision ?-? = revision a b = revision b speed ?40 = 40mhz package t = 52-pin tqfp u = 80-pin tqfp temperature range 6 = ?40 to 85c shipping optio n tape & reel packing = t
upsd34xx important notes 287/293 34 important notes the following sections describe the limitations that apply to the upsd34xx devices and the differences between revision a and b silicon. 34.1 usb interrupts with idle mode description an interrupt generated by a usb related event does not bring the mcu out of idle mode for processing. impact on application idle mode cannot be used with usb. workaround revision a - none identified at this time. revision b - corrected in silicon so that a usb interrupt that occurs w ill bring the mcu out of idle mode. 34.2 usb reset interrupt description when the mcu clock prescaler is set to a value other than f mcu = f osc (no division), a reset signal on the usb does not cause a usb interrupt to be generated. impact on application an mcu clock other than that equal to the frequency of the oscilla tor cannot be used. workaround revision a - the cpups field in the ccon0 register must be set to 000b (default after reset). the 3400 usb firmware examples set ccon0 register to 000b. revision b - corrected in silicon so that when an mcu clock presca ler is used, a reset signal on the usb does generate an interrupt. 34.3 usb reset description a usb reset does not rese t the usb sie's registers. impact on application a usb reset does not reset the usb sie's registers as does a power-on or hardware reset.
important notes upsd34xx 288/293 workaround revision a and b - when a usb reset is detected, the usb sie's registers must be initialized appropriately by the firmware. the 3400 usb firmware examples clear usb sie's registers if usb reset is detected. 34.4 data toggle description the data toggle bit is read only. impact on application the in fifo data toggle bit is controlled exclusively by the usb sie; therefore, it is not possible to change the state of the data toggle bit by firmware. workaround revision a - for cases where the data toggle bit must be reset, such as after a clear feature/stall request, sending the subsequent data on that endpoint twice results in getting the data toggle bit back to the state that it should be. revision b - a change in silicon was made so that the data toggle bit is reset by disabling and then enabling the respective endpoint's fifo. 34.5 usb fifo accessibility description the usb fifo is only accessible by firmware and not by a jtag debugger. impact on application using a jtag debugger, it is not possible to view the usb fifo's contents in a memory dump window. workaround revision a and b - none identified at this time. 34.6 erroneous resend of data packet description when a data packet is sent the respective in fifo busy bit is not automatically cleared by the usb sie. this can cause a data packet to be erroneously resent to the host in response to an in pid immediately after the first correct transmission of this data packet. impact on application since the data toggle in the retransmitted data packet is toggled from when the data was first sent, the host will treat this packet as valid. if the identified workaround is not
upsd34xx important notes 289/293 implemented then this extra and unexpected data packet would result in a communication breakdown. workaround revision a and b - in the usb isr, when an inx (x = the endpoint number of the in fifo) interrupt is detected, the in fifos respective busy bit should be unconditionally cleared. the upsd3400 usb firmware implements this workaround. 34.7 in fifo pairing operation description when fifo pairing is used on in endpoints, an erroneous resend of a data packet may occur. see the "erroneous resend of data packet" note as it also applies when in fifo pairing is used. impact on application see the "erroneous resend of data packet" note as the impact is the same when in fifo pairing is used. workaround revision a and b - see the "erroneous resend of data packet" note as the workaround is the same when in fifo pairing is used. 34.8 out fifo pairing operation description when data packets are received from the host and fifo pairing is used, the paired fifos may get out of order. impact on application the received data packets are read out of order compared to the way they were sent from the host. if the workaround is not implemented, the out of order packets would result in a communication breakdown. workaround revision a and b - in the usb isr, when an outx (x = the endpoint number of the out fifo) interrupt is detected, the out fifos re spective busy bit should be unconditionally cleared. the upsd3400 usb firmware implements this workaround. 34.9 missing ack to host re transmission of setup packet description if a host does not properly receive the ack (due to noise) from the upsd3400 in response to a setup packet, it will rese nd the setup packet but the upsd3400 will not respond with
important notes upsd34xx 290/293 an ack. the host will resend the setup packe t a number of times and if an ack is not received from the upsd3400, th e host will issue a usb reset and then enumerate it again. upon detecting a usb reset, the upsd3400 fi rmware will reset and initialize the usb sie putting the hardware back into the reset/initialized state so that when the next setup packet is received, the upsd3400 w ill respond with an ack to the host. impact on application if this occurs during enumeration, the im pact is minimal as the host will retry the enumeration. if it happens after enumeration, th e communication will break down between the host application and th e upsd3400 and will need to be re-established after the upsd3400 is reset and enumerated again. in extremely noisy environments, the upsd3400 may not communicate well over usb with the host application. workaround revision a and b - none identified at this time. 34.10 mcu jtag id description mcu jtag id changed to differentiate revisi on a from revision b silicon through the jtag port. the psd jtag id remains the same. revision a mcu jtag id - 0x0451f041 revision b mcu jtag id - 0x1451f041 impact on application there will be no impact on the application. the impac t will be to jtag production programming equipment that may need to distinguish be tween revision a and b mcu silicon if the firmware is different depending on the revision level. 34.11 port 1 not 5-volt io tolerant description the port p1 is shared with the adc module and as a result port p1 is not 5v tolerant. impact on application 5v devices should not be connected to port p1. workaround revision a and b - peripherals or gpio that require 5-volt io tolerance should be mapped to port 3 or port 4.
upsd34xx important notes 291/293 34.12 incorrect code execution when code bank s are switched description when a code bank is switched, the pfq/bc contain values from the previously selected bank and are not automatically flushed and reloaded from the newly selected code bank. impact on application. depending on the contents of the pfq/bc when the code bank is switched, improper code execution may result. workaround. the pfq/bc must be flushed when the code bank is changed. disabling and re-enabling the pfq/bc will flush them. the following instructions are an example of how to flush the pfq/bc: anl buscon,#03fh ;disable pfq/bc orl buscon,#0c0h ;enable pfq/bc bank switching is typically handled by tool vendors in a file called l51_bank.a51. the upsd tools offered by keil and raisonance now include an updated version of l51_bank.a51 for the upsd products that flushes the pfq/bc. the most recent banking examples available from st's website include the updated l51_bank.a51 files. 34.13 9th received data bit corru pted in uart modes 2 and 3 description. if the 9th transmit data bit is written by firmware into tb8 at the same time as a received 9th bit is being written by the hardware into rb8, rb8 is not correctly updated. this applies to both uart0 and uart1. typically, the 9th data bit is used as a parity bit to check for data transmission errors on a byte by byte basis. impact on application. uart modes 2 and 3 can't be used reliably in full-duplex mode. workaround. revision a and b - some options include: 1. only use mode 1 (8 data bits) for full-duplex communication. 2. use mode 1 and a packet based communication protocol with a checksum or crc to detect data transmission errors. 3. use uart0 in mode 2 or 3 for transmitting data and uart1 in mode 2 or 3 for receiving data. 4. use some form of handshaking to ensure that data is never transmitted and received simultaneously on a single uart configured in mode 2 or 3.
revision history upsd34xx 292/293 35 revision history table 186. document revision history date version revision details 04-feb-2005 1 first edition 30-mar-2005 2 added one note in section 1: summary description on page 9 added two notes in section 25: usb interface on page 143 changed values in table 175 on page 278 (turbo off column) added section 34: important notes on page 287 25-oct-2005 3 changed table on page 2 to add sales types with 32k sram changed figure 2 on page 10 changed figure 6 on page 19 corrected port pin p1.5 from adc6 to adc5 in table 2 on page 13 removed duplicate entry for 80-pin no. 11 in table 2 on page 13 changed figure 62 on page 185 updated table 101 on page 187 updated table 185 on page 286 11-jul-2006 4 pin descriptions, figure 3 on page 11 and figure 4 updated with v ref changed to av ref v ref changed to av ref throughout document figure 14 updated, correcting ccon[2:0] clarification of v cc , v dd , av cc supply voltages in section section 30: maximum rating on page 262 section 34: important notes updated with differences between silicon revisions a and b, and new important notes added. spi master controller corrected to 10mhz in features on first page latched address out modified, adding a8-a15 to pb0-pb7, section table 2.: pin definitions ucon register reset value changed from 00h to 08h throughout reference to usbce bi t corrected to upllce section 14 on page 59 incorrect references to uart#2 changed to uart#1 section 22.1 on page 112 uaddr register description enhanced, table 70 on page 155 usb interrupts section text expanded, section 25.4.3 on page 155 uifo register table modified, table 76 on page 159 uctl register table enhanced, table 80 on page 163 note added below table 81 on page 164 many modifications made to ucon register description, table 83 on page 166 an incorrect reference to capcomhn changed to capcomln section 27.7 on page 178 part numbering guide updated with b revision information section 33 on page 286 figure 41 on page 115 updated document reformatted note added related to non-support of external indirect addressing, in section 9.6 and in table 8 on page 44
upsd34xx 293/293 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorize representative of st, st products are not designed, authorized or warranted for use in military, air craft, space, life saving, or life sustaining applications, nor in products or systems, where failure or malfunction may result in personal injury, death, or severe property or environmental damage. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2006 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of UPSD3433E-40T6

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X